Results 1 to 2 of 2

Thread: DLookUp problem

  1. #1
    Join Date
    May 2014
    Posts
    35
    Provided Answers: 2

    Answered: DLookUp problem

    DLookup is not my friend.

    I have a Table called TBLStaff with fields Phone & EmployeeName. On a form titled FRMAvailableShifts I have a Combo Box titled Combo31 that has the employee names and an Unbound Textbox with the following code in the Control Source.

    Code:
    =DLookUp("Phone","TBLStaff","EmployeeName=" & Forms![FRMAvailableShifts]![Combo31])
    I have also tried,

    Code:
    =DLookUp("Phone","TBLStaff","EmployeeName=" & Me.Combo31.Value])
    I have tried,

    Code:
    = DLookup("Phone", "TBLStaff", "EmployeeName = '" & Me.Combo31.Value & "'")
    Returns an #Error
    I have tried to put the code in After Update, that does not work.

    Help please

  2. Best Answer
    Posted by healdem

    "so combo31 is?
    combo31 is where? the current form, another form?
    what value is in combo31.value when you try to run this code?

    do yourself a favour and get to grips with the integrated debugger

    learn how to examine variables, controls and so on. so youactually understand what your code is (or is not doing)
    the mnost likely reason for #error# is that you have referred to a control or variable or column that doesnt' exist in hte current 'scope' ie the VBA parser cannot resolve what somehting you have typed actgually is.

    that could be because its a spelling mistake. eg phone_no intead of phoneno
    it coudl be becuase youve used illegal reserved words or symbols say "employee name"


    but coulkd it just possibly be that the problem is that
    instead of:-
    Code:
    DLookUp("Phone","TBLStaff","EmployeeName=" & Forms![FRMAvailableShifts]![Combo31]
    it sholuld be
    =DLookUp("Phone","TBLStaff","EmployeeName='" & Forms![FRMAvailableShifts]![Combo31] & "'")

    you already know that text/alphanumeric values MUST be delimited, so I cannot possibly concieve of any reason why you thought your first trial would work
    http://www.dbforums.com/showthread.p...and-send-email

    To save yourself time, LEARN TO USE THE DEBUGGER"


  3. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so combo31 is?
    combo31 is where? the current form, another form?
    what value is in combo31.value when you try to run this code?

    do yourself a favour and get to grips with the integrated debugger

    learn how to examine variables, controls and so on. so youactually understand what your code is (or is not doing)
    the mnost likely reason for #error# is that you have referred to a control or variable or column that doesnt' exist in hte current 'scope' ie the VBA parser cannot resolve what somehting you have typed actgually is.

    that could be because its a spelling mistake. eg phone_no intead of phoneno
    it coudl be becuase youve used illegal reserved words or symbols say "employee name"


    but coulkd it just possibly be that the problem is that
    instead of:-
    Code:
    DLookUp("Phone","TBLStaff","EmployeeName=" & Forms![FRMAvailableShifts]![Combo31]
    it sholuld be
    =DLookUp("Phone","TBLStaff","EmployeeName='" & Forms![FRMAvailableShifts]![Combo31] & "'")

    you already know that text/alphanumeric values MUST be delimited, so I cannot possibly concieve of any reason why you thought your first trial would work
    http://www.dbforums.com/showthread.p...and-send-email

    To save yourself time, LEARN TO USE THE DEBUGGER
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •