D
Daiuy
I'm creating an application that controls visitor's badges.
I want to ensure that one badge can not be issued to more than one
individual at a time.
I have the application looking for possible duplications in the BadgeNumber
field.
I envision the security person having the visitor's ID and the visitor's
badge on their desk while they're inputing the data, so the highest
probability of a duplicate occuring is probably because that visitor's badge
was not logged back in by an entry in the Badge Returned Date field.
I have a message box that presents itself should a duplicate be found.
I'd like to give the user the option of immediately going to that record to
edit it.
I can't seem to navigate in BeforeUpdate
Here's my code:
Private Sub BadgeNumber_BeforeUpdate(Cancel As Integer)
Dim StrWhere As String
Dim varResult As Variant
Dim IntAnswer As Integer ''
With Me.BadgeNumber
If (.Value = .OldValue) Then
'do nothing
Else
StrWhere = "BadgeNumber = """ & .Value & """"
varResult = DLookup("ID", "tblAccessControl", StrWhere)
If Not IsNull(varResult) Then
IntAnswer = MsgBox("Would you like to go to that record
now?", vbExclamation + vbYesNo, "Duplicate Badge Number with Record " &
varResult)
If IntAnswer = vbYes Then
Else:
'do nothing
End If
Me.BadgeNumber.Undo
Cancel = True
End If
End If
End With
End Sub
I want to ensure that one badge can not be issued to more than one
individual at a time.
I have the application looking for possible duplications in the BadgeNumber
field.
I envision the security person having the visitor's ID and the visitor's
badge on their desk while they're inputing the data, so the highest
probability of a duplicate occuring is probably because that visitor's badge
was not logged back in by an entry in the Badge Returned Date field.
I have a message box that presents itself should a duplicate be found.
I'd like to give the user the option of immediately going to that record to
edit it.
I can't seem to navigate in BeforeUpdate
Here's my code:
Private Sub BadgeNumber_BeforeUpdate(Cancel As Integer)
Dim StrWhere As String
Dim varResult As Variant
Dim IntAnswer As Integer ''
With Me.BadgeNumber
If (.Value = .OldValue) Then
'do nothing
Else
StrWhere = "BadgeNumber = """ & .Value & """"
varResult = DLookup("ID", "tblAccessControl", StrWhere)
If Not IsNull(varResult) Then
IntAnswer = MsgBox("Would you like to go to that record
now?", vbExclamation + vbYesNo, "Duplicate Badge Number with Record " &
varResult)
If IntAnswer = vbYes Then
Else:
'do nothing
End If
Me.BadgeNumber.Undo
Cancel = True
End If
End If
End With
End Sub