NO!!!!!
Just add/change the lines I said - nothing else!
Also why have you commented out this line as I suggested
'Dim DeskNumber As String - OMIT - assuming its a field name
then defined it again in the following line
Dim DeskNumber As String
Looking at your last post again, you've commented out everything including all of the Else section
I'll try once more removing my comments & hopefully including all the code needed:
Code:
Private Sub txtDeskNumber_AfterUpdate()
Dim NewRoom As Integer
Dim NewDesk As String
Dim stLinkCriteria As String
Dim strRoom As String
'Assign the entered room number and desk number
NewRoom = Me.cboRooms
NewDesk = Me.txtDeskNumber
strRoom = Me.cboRooms.Column(1)
stLinkCriteria = "RoomID = " & NewRoom & " And DeskNumber = '" & NewDesk & "'"
If Me.cboRooms = DLookup("[RoomID]", "tblDeskInformation", stLinkCriteria) Then
MsgBox "This room, " & strRoom & ", has already been entered in database." _
& vbCr & vbCr & "with DeskNumber " & NewDesk & "" _
& vbCr & vbCr & "Please check customer name and address again.", vbInformation, "Duplicate information"
Me.Undo 'undo the process and clear all fields
Else
Me.DataEntry = False
DoCmd.FindRecord DeskNumber = '" & NewDesk & "'"
End If
End Sub
I'm still not absolutely sure about the FindRecord line above but hopefully it will now work.
Do try to understand this code rather than just copy code without thinking what it means