Results 1 to 3 of 3
  1. #1
    healey33 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    10

    DLookup Error 3075

    Hey,



    I have a form where I would like to read the value from another table, depending on the choice from a combobox and put it in a textbox on the current form. Basically, when the user selects a chassis from cboChassis (the values of this combobox are read from the field "System Name" in a table called "Systems"), I would like access to read the url (it is the drive location of a picture, in a text field) from the "Picture" field in the table "Systems" and put it in the textbox "txtPicHyperlink" on the current form.

    I receive the error: Run-time error '3075': Syntax error (missing operator) in query expression 'System Name = 'Full Antec System''. On the bolded line.

    "Full Antec System" was the value in the combobox so I know that part of the code is working correctly, but I cannot see what is wrong with my query expression!

    Here is the code:

    Code:
    Private Sub cboChassis_Change()
    Dim db As DAO.Database
    Set db = CurrentDb
    Dim strWhere As String
    Dim url As String
    'On Error Resume Next
    'strWhere = "System Name = " & Chr(39) & Me.cboChassis.Value & Chr(39)                     'Trying different ways of reading the value from the form
    strWhere = "System Name = " & Chr(39) & Forms![LabRequestForm]!Chassis & Chr(39)
    url = DLookup("Picture", "Systems", strWhere)
    txtPicHyperlink.Value = url
    'txtPicHyperlink.Value = strWhere      'for viewing strWhere - I would comment out the 2 lines above this and uncomment this one to view it
    End Sub
    When I put strWhere in the textbox instead of url and comment out the DLookup line and the one below it, I see the query is System Name = 'Full Antec System'. This looks correct to me, so I am not sure what is wrong! Please let me know if any clarification is needed.

    Any help is greatly appreciated!

    Thanks in advance,
    Healey33

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    The strWhere string is not closed.

    Try this:
    Code:
    strWhere = "System Name = " & Chr(39) & Forms![LabRequestForm]!Chassis & Chr(39) & Chr(34)
    Chr(34) is ASCII for the double quote (")

    Another way to write the string is:
    Code:
    strWhere = "System Name = '" & Forms![LabRequestForm]!Chassis & "'"

    Also,
    - you do not need to type ".Value". It is the default property. It doesn't hurt....... but you can save some typing.
    - You do not have a declaration for the variable "txtPicHyperlink" (Dim statement)

  3. #3
    healey33 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Posts
    10
    Thanks so much for the quick reply! That took care of it!

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

Similar Threads

  1. Replies: 3
    Last Post: 03-05-2013, 11:17 AM
  2. Replies: 5
    Last Post: 09-05-2012, 09:28 AM
  3. Replies: 6
    Last Post: 05-30-2012, 12:32 PM
  4. Replies: 5
    Last Post: 03-27-2012, 01:40 PM
  5. Getting Error 3075
    By boywonder in forum Programming
    Replies: 4
    Last Post: 05-23-2011, 05:06 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