Link to home
Start Free TrialLog in
Avatar of chobe
chobe

asked on

Dlookup/Combo box problem

After finally getting Dlookup to work I now realize there is a new problem;  I am using Dlookup to  match a users Windows log in name with the LogonID in my user table to populate a combo box with the users full name.  This is working, however control list only contains my value.  If the users logon name does not exist (or has changed) in my user table, the correct name is not populated in the control.  How can I check for a match and display a msgbox if not found before populating the control?
SystemUser = GetUser() 'function that gets current Windows log on name
    Me.cboRequestor = DLookup("FullName", "tblResources", "LogonID='" & SystemUser & "'") ' populates combo box

Open in new window

Avatar of Michael Vasilevsky
Michael Vasilevsky
Flag of United States of America image

Use an If Then statement...
Something like the below.
SystemUser = GetUser() 'function that gets current Windows log on name
    If nz(DLookup("FullName", "tblResources", "LogonID='" & SystemUser & "'"),"999")=999 then
          Me!cboRequestor = ""
    else
          Me!cboRequestor = DLookup("FullName", "tblResources", "LogonID='" & SystemUser & "'")
    End if

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Michael Vasilevsky
Michael Vasilevsky
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of chobe
chobe

ASKER

Thanks - Work great!