Results 1 to 8 of 8
  1. #1
    KieranJ2020 is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2022
    Posts
    2

    DLookup driving me mad

    Hi All,


    New user so apologies in advance if i have posted this in the wrong place, but I cannot for the life of me understand why this dlookup is returning a "Compile Error Expected: ="

    The dlookup is

    dlookup("ChecksCompleted","dbo_tblCurrentStrategy" , "EngineerName =: '" & me.cboOpCompleting.Value & "'")

    dbo_tblCurrentStrategy is a linked table which resides on an SQL Server and me.cboOpCompleting.Value is a combo box which has a list of names. The dlookup is sitting in the vba of the form itself.

    I have tried many iterations and it is slowly driving me to the point of insanity.

    Thank you in advance for any help!

    Kieran

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,934
    would have thought the error message was clear enough

    "EngineerName =: '"

    should be

    "EngineerName = '"

    or if you are trying to exclude the value

    "EngineerName <> '"




  3. #3
    KieranJ2020 is offline Novice
    Windows 10 Office 365
    Join Date
    Oct 2022
    Posts
    2
    Thank you for taking the time to reply to me! I've changed the criteria to what you suggested and i am still getting the same error message


  4. #4
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    I have a different notion of the error: because there is nothing on the left side for it to be equal to; i.e.
    something = dlookup("ChecksCompleted","dbo_tblCurrentStrategy" , "EngineerName = '" & me.cboOpCompleting.Value & "'")

    The colon should not be there, but if it is, it does not generate a compile error for me but it does raise a syntax error at run time. However not passing the return value of the DLookup function to something does generate a compile error.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,557
    Quote Originally Posted by KieranJ2020 View Post
    Hi All,
    New user so apologies in advance if i have posted this in the wrong place, but I cannot for the life of me understand why this dlookup is returning a "Compile Error Expected: ="

    The dlookup is

    dlookup("ChecksCompleted","dbo_tblCurrentStrategy" , "EngineerName =: '" & me.cboOpCompleting.Value & "'")

    dbo_tblCurrentStrategy is a linked table which resides on an SQL Server and me.cboOpCompleting.Value is a combo box which has a list of names. The dlookup is sitting in the vba of the form itself.

    I have tried many iterations and it is slowly driving me to the point of insanity.

    Thank you in advance for any help!

    Kieran
    You appear to be confusing keyword parameters with the actual contents of a parameter?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Post 3 was moderated, I'm posting to trigger email notifications.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,557
    Quote Originally Posted by KieranJ2020 View Post
    Thank you for taking the time to reply to me! I've changed the criteria to what you suggested and i am still getting the same error message

    Perhaps show all the code you are using?
    As mentioned something has to be assigned the result of the dlookup?

    When in doubt, look up the syntax.
    https://support.microsoft.com/en-us/...b-bed10dca5937
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I should have mentioned the moderated post had a failed attachment. This may help:

    https://www.accessforums.net/showthread.php?t=70301
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. this is driving me nuts
    By Raleyoz in forum Access
    Replies: 20
    Last Post: 06-02-2015, 08:10 AM
  2. switchboard driving me nuts
    By bbxrider in forum Forms
    Replies: 4
    Last Post: 12-06-2014, 06:24 PM
  3. Dlookup driving me crazy
    By NJMike64 in forum Modules
    Replies: 3
    Last Post: 04-19-2014, 01:58 PM
  4. Parameters driving me mad
    By reburton in forum Programming
    Replies: 14
    Last Post: 10-31-2013, 01:35 PM
  5. Pls help... driving me insane!
    By Maverick1501 in forum Reports
    Replies: 1
    Last Post: 03-31-2010, 06:26 AM

Tags for this Thread

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