I am a beginner, and this is my first post, just to get that out first. Ive highlighted the problem im having in bold, but basically Im having trouble searching the table with the given criteria. Im trying to shorten my code by using this for loop. Currently im running 40 odd dlookup.
I have a database of users with desk numbers assigned to them and ive created a form with a layout that shows where their desk is using labels, but im trying to use the labels caption as search criteria in the dlookup. it works if I use the exact labels name and i started having problems if I use me.control. is there anything else I can use? I can set the labels caption using me.control but not search with it.
For deskNumber = 1 To 3
strDesk = "desk" & deskNumber
strDeska = "desk" & deskNumber & "a"
If ("Desk_No") <> "Empty" Then
If Me.Controls(strDesk).Caption = DLookup("Full_Name", "Tbl_Employee", "Desk_No='" & **Me.Controls(strDeska).Caption** & "'") = vbNullString Then
Else
Me.Controls(strDesk).Caption = "Empty"
End If
Else
Me.Controls(strDesk).Caption = "Empty"
End If
Next deskNumber