I have a table Called Apps OS that has one field called Number which is the number of the club entered. When creating a form from this table in order to create a Before Update Event, can I create it as a datasheet form? Or is there a preference in form I should be using. Also, I am having an issue programming the Before Update Event into the form under the Number Field. I have typed in as follows:
Private Sub Number_BeforeUpdate(Cancel As Integer)
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SID = Me.txtNumber.Value
stLinkCriteria = "[txtNumber]=" & "'" & SID & "'"
'Check Apps OS table for duplicate Number
If DCount("txtNumber", "tblApps OS", _
stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning Number " _
& SID & " has already been entered." _
& vbCr & vbCr & "You will now been taken to the record.", _
vbInformation, "Duplicate Information"
'Go to record of original Number
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub
I attempt to make an a duplicate entry to test it and it is not working. WHat am I doing wrong.
Private Sub Number_BeforeUpdate(Cancel As Integer)
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SID = Me.txtNumber.Value
stLinkCriteria = "[txtNumber]=" & "'" & SID & "'"
'Check Apps OS table for duplicate Number
If DCount("txtNumber", "tblApps OS", _
stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning Number " _
& SID & " has already been entered." _
& vbCr & vbCr & "You will now been taken to the record.", _
vbInformation, "Duplicate Information"
'Go to record of original Number
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub
I attempt to make an a duplicate entry to test it and it is not working. WHat am I doing wrong.
Last edited: