Results 1 to 13 of 13
  1. #1
    funkygoorilla is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    93

    Dlookups

    Hi,
    I have two forms, with the same dlookup values on it. In form A, the lookups work just fine. On form B, the lookups work so inconsistently I don't know how to fix it. Is there a setting for lookups or something?
    Here is my example;
    =DLookUp("[First Name]","tblEmployees","[Seniority ID] = Form![SeniorityIDResult]"

    I am wanting the lookup to find the first name of the employee by looking at the field called SeniorityIDResult on the current form. It will work and sometimes wont, I don't know what else to check. Could it be because I have a piece of code to clear all the fields on load? And if so, I use the same code on another form, and the Dlookups work perfectly. Any help or suggestions would be awesome!
    FunkyG

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Assuming the [Seniority ID] is numeric, try:
    =DLookUp("[First Name]","tblEmployees","[Seniority ID] = " & Me.[SeniorityIDResult]

  3. #3
    funkygoorilla is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    93
    Hi RuralGuy thanks for the reply. Yes the field is numeric, but I tried as you suggested and it still does not take/ Now I have the #NAME? error in my field.
    This is what I am trying;
    =DLookUp("[First Name]","tblEmployees","[Seniority ID] = " & [Me].[SeniorityIDResult])

    Funkyg

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    This indicates to me that there is *no* control on the current form named SeniorityIDResult.

  5. #5
    funkygoorilla is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    93
    Ok, so I got it. I found an exact demo of what I was trying to do on this site;
    http://msdn.microsoft.com/en-us/libr...ffice.12).aspx
    Thanks for the replies!
    FunkyG

  6. #6
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Quote Originally Posted by funkygoorilla View Post
    Hi RuralGuy thanks for the reply. Yes the field is numeric, but I tried as you suggested and it still does not take/ Now I have the #NAME? error in my field.
    This is what I am trying;
    =DLookUp("[First Name]","tblEmployees","[Seniority ID] = " & [Me].[SeniorityIDResult])

    Funkyg
    And just a reminder is that ME is only good in VBA and not in control sources.

    And when referencing forms you use

    Forms!FormNameHere

    (with the S - and not Form!)

  7. #7
    funkygoorilla is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    93
    Hi Bob,
    Speaking of this issue. When I load the form with these Dlookups in the controls, it pops up an error in each of the fields. It still functions, but is there something I can to get that to not show error?
    Thanks, FunkyG.

  8. #8
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Sounds like you have referenced something that it can't find. What is the exact message?

  9. #9
    funkygoorilla is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    93
    Hi,
    Its the #Error. It appears right when I open the form that uses the DLookups as mentioned before. Is there like a pre setting or something I cas use. Only asking because the DLookup works as it should, but that could throw some people off if it appears right when you open the form.
    Thanks, FunkyG!

  10. #10
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Post the EXACT control source formula you are using for any of the DLookups.

  11. #11
    funkygoorilla is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    93
    Hi Bob,
    Here is the exact DLookup I am using.
    =DLookUp("[First Name]","tblEmployees","[Seniority ID] = " & [Forms]![frmVehicleInformationStarting]![SeniorityIDResult])
    When the form loads, it displays #Error in the SeniorityIDResult field. It does disappear once you enter anything in the form, but I would like to see if it is possible to get it to not show.

  12. #12
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Try this instead:

    =IIF(Len([Forms]![frmVehicleInformationStarting]![SeniorityIDResult] & "") = 0, "",DLookUp("[First Name]","tblEmployees","[Seniority ID] = " & [Forms]![frmVehicleInformationStarting]![SeniorityIDResult]))

  13. #13
    funkygoorilla is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    93
    Hi Bob,
    Thanks so much for the reply. It worked like a charm. However I am not sure what the control is doing. Is it basically an IF statement saying that if the SeniorityIDResult field is empty, then to lookup the value in the tblEmployees?
    Either way, thats what I needed. Thanks again! FunkyG

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

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