• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 305
  • Last Modified:

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

0
chobe
Asked:
chobe
  • 3
1 Solution
 
Michael VasilevskySolutions ArchitectCommented:
Use an If Then statement...
0
 
Michael VasilevskySolutions ArchitectCommented:
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

0
 
Michael VasilevskySolutions ArchitectCommented:
Oh if you want a message box use

    If nz(DLookup("FullName", "tblResources", "LogonID='" & SystemUser & "'"),"999")=999 then
         msgbox "Your User Name was not found. Please contact Chobe" 
         Me!cboRequestor = ""
    else
          Me!cboRequestor = DLookup("FullName", "tblResources", "LogonID='" & SystemUser & "'")
    End if

Open in new window

0
 
chobeAuthor Commented:
Thanks - Work great!
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now