Results 1 to 6 of 6
  1. #1
    dcdimon's Avatar
    dcdimon is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2013
    Location
    Bradenton, FL
    Posts
    71

    Three criteria in Dlookup not working?

    I'm trying to get a dlookup to work with three criteria. if I remove one (any one) it works. The minute I insert the third back into the script (vb) it won't pull up the data. My dlookup is below:



    Code:
    ctl.ControlSource = DLookup("ControlSource", "UFO_CIL_selectedFieldListArchiveT", "FieldNumber = " & i & " and EquipmentNumber = '" & Forms!UFO_OperatorFrameF!BlankPageF.Form!SelectedEquipmentTxt & "' and shift = 'all'")
    I'm also getting an error that makes no sense to me:

    Syntax error (missing operator) in query expression 'FieldNumber = 1 and EquipmentNumber = '107309' and shift = 'all'

    I've been banging my head against the monitor long enough I need to phone a friend. Can anyone tell me what I'm doing wrong?

    Thanks,
    DD

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Is EquipmentNumber a Text value or a Number?

  3. #3
    dcdimon's Avatar
    dcdimon is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2013
    Location
    Bradenton, FL
    Posts
    71
    It's text, the only number/integer is the string i.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    It may be a timing issue. Try adding a Command Button to the form that will display the same DLookup() value when you press it.

  5. #5
    dcdimon's Avatar
    dcdimon is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2013
    Location
    Bradenton, FL
    Posts
    71
    Okay I figured it out.

    My script is/was working. I had a problem with a query that was being used prior to the table the DLookup is using and the script wasn't able to pull out data because it was being asked for something that didn't exist. Once I fixed my query then all was golden.

    So, end result: Access was doing what it was asked. User had a brain cramp.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Thanks for the update.

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

Similar Threads

  1. Dlookup not working in Subform
    By keiath in forum Forms
    Replies: 1
    Last Post: 04-23-2014, 09:03 AM
  2. Autofill using DLookup not working
    By BBonexx in forum Access
    Replies: 2
    Last Post: 01-08-2013, 09:18 PM
  3. DLookup isn't working
    By cec in forum Access
    Replies: 7
    Last Post: 12-28-2012, 12:21 PM
  4. order by dlookup not working
    By broof in forum Queries
    Replies: 3
    Last Post: 01-11-2011, 03:15 PM
  5. DLookup code not working
    By lukekelly in forum Programming
    Replies: 9
    Last Post: 06-15-2010, 06:08 AM

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