Results 1 to 3 of 3
  1. #1
    LOTUS is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jan 2016
    Posts
    2

    DLookup run-time error '3075': Syntax error (missing operator)


    Hi,

    I receive an error when I use the DLookup function in a form: "Run-time error '3075': Syntax error (missing operator) in query expression 'id_Item=16ERG60BMA'". 16ERG60BMA is the ID for the item. The code I have setup for this is:

    Code:
    Private Sub textItemID_AfterUpdate()    
        textItemDescription = DLookup("item_Description", "table_Items", "id_Item=" & id_Item)
    End Sub
    I am not sure what is missing or going wrong. The field "item_Description" exists in "table_Items" and has data in it; the "id_Item" is entered by the user on the form and is a combo box limiting the user to only the "id_Item" in the "table_Items". Spelling is correct.

    I have used this function elsewhere with the same database and it works fine. Here is an example:
    Code:
     Private Sub textDistributorID_AfterUpdate()
        textDistributorName = DLookup("distributor_Name", "table_Distributor", "id_Distributor=" & id_Distributor)
        textDistributorAddress1 = DLookup("distributor_Address1", "table_Distributor", "id_Distributor=" & id_Distributor)
        textDistributorAddress2 = DLookup("distributor_Address2", "table_Distributor", "id_Distributor=" & id_Distributor)
        textDistributorAddress3 = DLookup("distributor_Address3", "table_Distributor", "id_distributor=" & id_Distributor)
        textDistributorCity = DLookup("distributor_City", "table_Distributor", "id_Distributor=" & id_Distributor)
        textDistributorState = DLookup("distributor_State", "table_Distributor", "id_Distributor=" & id_Distributor)
        textDistributorZipCode = DLookup("distributor_ZipCode", "table_Distributor", "id_Distributor=" & id_Distributor)
        textDistributorCountry = DLookup("distributor_Country", "table_Distributor", "id_Distributor=" & id_Distributor)
    End Sub
    If there is any other information I can provide, please let me know!


    Thank you.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    your ID must be string so add quotes....

    textItemDescription = DLookup("item_Description", "table_Items", "id_Item='" & id_Item & "'")

  3. #3
    LOTUS is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jan 2016
    Posts
    2
    Quote Originally Posted by ranman256 View Post
    your ID must be string so add quotes....

    textItemDescription = DLookup("item_Description", "table_Items", "id_Item='" & id_Item & "'")

    That worked!! Thank you so much.

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

Similar Threads

  1. Replies: 2
    Last Post: 09-10-2014, 11:30 AM
  2. Replies: 3
    Last Post: 03-05-2013, 11:17 AM
  3. Replies: 4
    Last Post: 07-25-2012, 04:01 AM
  4. Replies: 6
    Last Post: 05-30-2012, 12:32 PM
  5. Replies: 5
    Last Post: 03-27-2012, 01:40 PM

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