So you do not want the single quotes:
Code:Private Sub PostNumber_AfterUpdate() Dim SID As String Dim stLinkCriteria As String Dim rsc As DAO.Recordset Set rsc = Me.RecordsetClone SID = Me.PostNumber stLinkCriteria = "[PostNumber]=" & SID 'Check Employee Table table for duplicate If DCount("PostNumber", "Employee Table", stLinkCriteria) > 0 Then 'Undo duplicate entry Me.Undo 'Message box warning of duplication MsgBox "Warning Post Number " _ & SID & " has already been entered." _ & vbCr & vbCr & "You will now been taken to the record.", _ vbInformation, "Duplicate Information" 'Go to record of original record rsc.FindFirst stLinkCriteria Me.Bookmark = rsc.Bookmark End If Set rsc = Nothing End Sub
i still get the error my friends...is it possible that the error can be somewhere before the Post Number???
What error are you getting?
Hmm...any chance you can post the db or at least enough of it for me to play with?
Try my code instead:-
Still use the beforeupdate event
The logic of original code is ok.
I have seen a few similar examples before.
The change is highlighted for easy reference.
Code:Private Sub PostNumber_BeforeUpdate(Cancel As Integer) Dim SID As Long Dim stLinkCriteria As String Dim rsc As DAO.Recordset Set rsc = Me.RecordsetClone SID = Me.PostNumber stLinkCriteria = "[PostNumber]=" & SID 'Check Employee Table table for duplicate If DCount("PostNumber", "Employee Table", stLinkCriteria) > 0 Then 'Undo duplicate entry Cancel = True Me.Undo 'Message box warning of duplication MsgBox "Warning Post Number " _ & SID & " has already been entered." _ & vbCr & vbCr & "You will now be taken to the original record.", _ vbInformation, "Duplicate Information" 'Go to record of original record rsc.FindFirst stLinkCriteria Me.Bookmark = rsc.Bookmark End If Set rsc = Nothing End Sub
i still get the error even if i change it the way u told me.
if u guys dnt mind pm you mail addss and i will send u my DB its about 1.5Mb
thanks
You can zip it up and attach it to a post here. Just scroll down to Manage Attachments.
Pls upload the file in access 2000 format
I've tried my code in my access db and it works as expected.
By the way, Have you enabled DAO by reference?
Try attaching the db directly. The zip you posted is not valid. This forum can handle up to a 2MB file.
sorry here it is...
I do not see a PostNumber control anywhere on the form nor any of the code we have been discussing.