Results 1 to 8 of 8
  1. #1
    WAVP375 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171

    Checking for valid return of DLookUp

    I have a valid DLookUp text box that returns the proper data. I am attempting to determine if the DLookUp has been executed or if the returned value is blank.


    I have used the If IsNull, The IIf(IsNull0, and the If Len(Me.Text & vbNullString) = 0 possibilities and all generate an error of some sort.
    Any other possibilities?

    Thanks

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,235
    Have you tried =IIF(isnull(dlookup("","","")),"N/A",dlookup("","","")) as the control source of the text box?

    Cheers,
    Vlad

  3. #3
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,705
    Remove the dlookup from the data source property and put it in the form_current event:

    Code:
    Form_current
        me.mytext = nz(dlookup(......),"")
        if len(me.mytext & vbnullstring) = 0 then
            me.mytext = "Not Found"
        endif
    end sub

  4. #4
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    Maybe I didn't understand the question but, why not =nz(dlookup(......),"Not Found!") in control-source of textbox?
    Or with =dlookup(......) in control-source and with @;[Red]"Not Found!" format?

  5. #5
    WAVP375 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    A little more explaination. The dlookup is used to visually verify that a valid badge number has been entered into another texbox which is used in the dlookup.
    =DLookUp("[FullName]","[TblVolunteers]","[Badge]="&[Forms]![FrmCompletionDate]![Badge]
    Will either of the suggestions work in this situation. Meanwhile I will test them.

    Thanks

  6. #6
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,705
    The algorithm for this sounds all wrong. I assume you want to validate whether a badge exists for the volunteer. What if it does exist but frmCompletionDate has the wrong badge number entered?
    A more rigorous check would be NZ(Dlookup("[Badge]","TblVolunteers","VolunteerID=" & me.VolunteerID),"")
    You would need to adjust the VolunteerID field name for your circumstances.
    Last edited by davegri; 01-17-2019 at 09:00 AM. Reason: add NZ

  7. #7
    WAVP375 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    There is no way programmatically to check if the proper badge has been entered, that's why I want to display the name that is associated with the badge. The visual check determines if it is the correct number.
    I am more looking for ,Was a badge number entered and is there a name or did it return a blank. Either of those conditions I can deal with. Thanks, I will give some of these suggestions a shot.
    I will be back later

  8. #8
    WAVP375 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    Thanks to all of You. Vlad has solved my problem..

Please reply to this thread with any new information or opinions.

Similar Threads

  1. DLookup return value
    By faythe1215 in forum Programming
    Replies: 3
    Last Post: 03-15-2015, 06:18 PM
  2. Replies: 3
    Last Post: 03-20-2012, 10:31 AM
  3. Checking if a year exists via DLookup
    By walter189 in forum Programming
    Replies: 6
    Last Post: 07-22-2011, 10:37 PM
  4. DLookup not recognizing valid record/type mismatch
    By walter189 in forum Programming
    Replies: 3
    Last Post: 07-21-2011, 07:03 AM
  5. Checking user input is valid
    By AccessPoint in forum Access
    Replies: 4
    Last Post: 07-18-2010, 06:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums