D
Daiuy
I'm creating an application that controls visitor's badges to our facility.
I want to ensure that one badge can not be issued to more than one
individual at a time. I've borrowed the following code but I'd like the
cursor to remain in the BadgeNumber text box if the message box is triggered.
Eventually, I will add a button to the message box that will allow me to go
to the record called out in the message box - that's why I'd like to know
where the duplication is occuring.
Again, if a duplicate is found - I'd like the cursor to remain in
BadgeNumber text box.
Private Sub BadgeNumber_AfterUpdate()
Dim StrWhere As String
Dim varResult As Variant
With Me.BadgeNumber
If (.Value = .OldValue) Then
'do nothing
Else
StrWhere = "BadgeNumber = """ & .Value & """"
varResult = DLookup("ID", "tblAccessControl", StrWhere)
If Not IsNull(varResult) Then
MsgBox "That Badge has Already been Issued in Record " &
varResult, 16
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've borrowed the following code but I'd like the
cursor to remain in the BadgeNumber text box if the message box is triggered.
Eventually, I will add a button to the message box that will allow me to go
to the record called out in the message box - that's why I'd like to know
where the duplication is occuring.
Again, if a duplicate is found - I'd like the cursor to remain in
BadgeNumber text box.
Private Sub BadgeNumber_AfterUpdate()
Dim StrWhere As String
Dim varResult As Variant
With Me.BadgeNumber
If (.Value = .OldValue) Then
'do nothing
Else
StrWhere = "BadgeNumber = """ & .Value & """"
varResult = DLookup("ID", "tblAccessControl", StrWhere)
If Not IsNull(varResult) Then
MsgBox "That Badge has Already been Issued in Record " &
varResult, 16
End If
End If
End With
End Sub