I have a function that is parsing a Fullname then looking up a specific userid. The problem is that it returns the wrong userid from the table. Below is the code. Any ideas?
Public Function FullNameSplit(FullName, LN, FN, UserID)
Dim stLinkCriteria As String
LN = Trim(Left(FullName, InStr(FullName, ",") - 1))
MsgBox "LastName = " & LN, vbOKOnly
FN = Trim(Right(FullName, Len(FullName) - InStr(FullName, ",") - 1))
MsgBox "FirstName = " & FN, vbOKOnly
stLinkCriteria = "'[LastName] =" & LN & "'"
MsgBox "stlinkCriteria = " & stLinkCriteria
LID = DLookup("[UID]", "Tbl-Employee", stLinkCriteria)
MsgBox "UserID = " & UserID, vbOKOnly
End Function
The MsgBoxes were for troubleshooting. In my example I pass the function Smith,Joe. What I see in return is:
Lastname = Smith
Firstname = Joe
stLinkCriteria = '[Lastname] =Smith'
UserID = JaneDoeID
Public Function FullNameSplit(FullName, LN, FN, UserID)
Dim stLinkCriteria As String
LN = Trim(Left(FullName, InStr(FullName, ",") - 1))
MsgBox "LastName = " & LN, vbOKOnly
FN = Trim(Right(FullName, Len(FullName) - InStr(FullName, ",") - 1))
MsgBox "FirstName = " & FN, vbOKOnly
stLinkCriteria = "'[LastName] =" & LN & "'"
MsgBox "stlinkCriteria = " & stLinkCriteria
LID = DLookup("[UID]", "Tbl-Employee", stLinkCriteria)
MsgBox "UserID = " & UserID, vbOKOnly
End Function
The MsgBoxes were for troubleshooting. In my example I pass the function Smith,Joe. What I see in return is:
Lastname = Smith
Firstname = Joe
stLinkCriteria = '[Lastname] =Smith'
UserID = JaneDoeID