I am at a loss on how to write a DLookup to find the value of a field in a table based upon the value of a variable that relates to a different field in that table.
Scenario is:-
Tble 1 contains #ID (Long), Name (String) etc.
Tbl 2 has Name, Date etc but not an ID.
I have a form which has takes info for Tbl 2 and I have caputured the ID from the Login function.
I now want to compare the Name Chosen for Tbl 2 with the Login ID I have captured to see if the Name in both Tbl 1 & the Form for Tbl 2 Match.
I am getting really confused with the logic and wonder if you can advise me.
My Current Code is as follows:-
LoginID = the Login info captured...this will equal an Employee Record ID field
I Need to look in the tblEmployees and find the name associated with the ID which = LoginID.
Once I have this I can compare Names to see if they are equal.
I know my code is wrong but my brain has gone and I cannot figure out the logic.
Scenario is:-
Tble 1 contains #ID (Long), Name (String) etc.
Tbl 2 has Name, Date etc but not an ID.
I have a form which has takes info for Tbl 2 and I have caputured the ID from the Login function.
I now want to compare the Name Chosen for Tbl 2 with the Login ID I have captured to see if the Name in both Tbl 1 & the Form for Tbl 2 Match.
I am getting really confused with the logic and wonder if you can advise me.
My Current Code is as follows:-
Code:
If loginID = DLookup("strEmpName", "tblEmployees", "[lngEmpID] =" & Forms![frmBookings.BookName]) Then
'MsgBox ("Login Name Matches Login ID")
'Me!BookName.SetFocus
'Else
'MsgBox ("Not Matched")
'Exit Sub
'End If
I Need to look in the tblEmployees and find the name associated with the ID which = LoginID.
Once I have this I can compare Names to see if they are equal.
I know my code is wrong but my brain has gone and I cannot figure out the logic.
Comment