G
Guest
I am using DLookup in VBA to pull certain values from a table. I have this
working successfully.
However, now I want to use Dlookup to determine if a value is not in a table
so I may provide a message to the user and close the form. I have created a
message box showing that nothing was found in my Dlookup, but when I try to
use a If Isnull or If field = "", to return my message it does not seem to
work. Am I doing something incorrectly or is there a different or better way
to do this?
strName = DLookup("[First Name]", "Users", "[Userid] = " & Chr$(34) _
& strID & Chr$(34)) & " " & DLookup("[Last Name]", "Users",
"[Userid] = " _
& Chr$(34) & strID & Chr$(34))
MsgBox "strName = " & strName 'testing value found
If IsNull(strName) Then
Msgbox "Second Message Here"
End If
Any guideance would be greatly appreciated.
Thanks!
working successfully.
However, now I want to use Dlookup to determine if a value is not in a table
so I may provide a message to the user and close the form. I have created a
message box showing that nothing was found in my Dlookup, but when I try to
use a If Isnull or If field = "", to return my message it does not seem to
work. Am I doing something incorrectly or is there a different or better way
to do this?
strName = DLookup("[First Name]", "Users", "[Userid] = " & Chr$(34) _
& strID & Chr$(34)) & " " & DLookup("[Last Name]", "Users",
"[Userid] = " _
& Chr$(34) & strID & Chr$(34))
MsgBox "strName = " & strName 'testing value found
If IsNull(strName) Then
Msgbox "Second Message Here"
End If
Any guideance would be greatly appreciated.
Thanks!