Missing operator in DLookup function help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lumpy
    New Member
    • Oct 2007
    • 69

    Missing operator in DLookup function help

    Hi all,
    I am having a problem with a line of code in access vba. I am trying to use the DLookup function to check whether or not a record already exists with a dealer name. Once I know if it exists or not, later on in the code I will run some sql to either insert a new record or update an existing record. But, I am getting a syntax error that says I am missing an operator. I have googled around but to no luck, any help would be much appreciated.

    The line of code I am having trouble with is...
    Code:
    dtest = DLookup("[DealerBiz]", "[Dealer_Table]", "[DealerBiz] =" & Me!Dealer)
    DealerBiz is the field I want to search through within the Dealer_Table, and I want to look for a match of the Me!Dealer box within the DealerBiz field.

    I have tried messing around with the syntax any way that my little access knowledge could come up with but no such luck. Once again, any help or direction would be greatly appreciated.

    Thank you!
  • convexcube
    New Member
    • Dec 2007
    • 47

    #2
    Originally posted by Lumpy
    Hi all,
    I am having a problem with a line of code in access vba. I am trying to use the DLookup function to check whether or not a record already exists with a dealer name. Once I know if it exists or not, later on in the code I will run some sql to either insert a new record or update an existing record. But, I am getting a syntax error that says I am missing an operator. I have googled around but to no luck, any help would be much appreciated.

    The line of code I am having trouble with is...
    Code:
    dtest = DLookup("[DealerBiz]", "[Dealer_Table]", "[DealerBiz] =" & Me!Dealer)
    DealerBiz is the field I want to search through within the Dealer_Table, and I want to look for a match of the Me!Dealer box within the DealerBiz field.

    I have tried messing around with the syntax any way that my little access knowledge could come up with but no such luck. Once again, any help or direction would be greatly appreciated.

    Thank you!
    It seems as though [DealerBiz] is a string. If this is the case then your Dlookup statement needs to have some quotes around Me!Dealer. Try:

    Code:
    dtest = DLookup("[DealerBiz]", "[Dealer_Table]", "[DealerBiz] ='" & Me!Dealer & "'")
    or
    Code:
    dtest = DLookup("[DealerBiz]", "[Dealer_Table]", "[DealerBiz] =" & chr(34) & Me!Dealer & chr(34))
    Hope this helps.

    Kind Regards,
    Ken.

    Comment

    • Lumpy
      New Member
      • Oct 2007
      • 69

      #3
      Originally posted by convexcube
      It seems as though [DealerBiz] is a string. If this is the case then your Dlookup statement needs to have some quotes around Me!Dealer. Try:

      Code:
      dtest = DLookup("[DealerBiz]", "[Dealer_Table]", "[DealerBiz] ='" & Me!Dealer & "'")
      or

      Hope this helps.

      Kind Regards,
      Ken.
      Worked like a Charm, Thanks a million Ken!

      Comment

      Working...