Results 1 to 9 of 9
  1. #1
    nick243 is offline Competent Performer
    Windows 7 64bit Access 2002
    Join Date
    May 2016
    Posts
    185

    DLookup Run Time Error 3075


    Hi, I am having an issue with not finding the criteria in the domain. I cannot get the MEF# to populate and find it in Sheet1. I know there is a difference in code from a numeric value to a text value. MEF# is a text value. I tried changing the code to use the text value correctly but nothing has worked out. Any help would be appreciated. Thanks, Nick The problem begins after the comment Check if MEF# is valid.

    Code:
    Private Sub Command39_Click()
    Dim MEFVar, MEFVarX
    
    
    ' Check that the MEF is 6 digits
    MEFVar = InputBox("Enter a MEF Number to start a new Chargeback:", "Open New Chargeback")
    If Len(MEFVar) <> 6 Then
        MsgBox MEFVar & " is not a valid MEF Number."
        End
    End If
    
    
    'Check that MEF is valid
    
    
    MEFVarX = DLookup("MEF#", "Sheet1", "MEF# = " & MEFVar)
    If IsNull(MEFVarX) = True Then
        MEFVarX = MsgBox(MEFVar & " is not found on the list of MEF numbers. " & vbNewLine & vbNewLine & "Do you want to write a Chargeback for this MEF " & MEFVar & "?", 4)
        If MEFVarX <> 6 Then
            End
        End If
    End If

  2. #2
    PLangley is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Sep 2017
    Location
    Franklin, VA, USA
    Posts
    7
    Hi Nick243,
    If MEF# is a text value (not a numeric data type), you must put single quotes around the value you are passing in the criteria as follows:
    MEFVarX = DLookup("MEF#", "Sheet1", "MEF# = '" & MEFVar & "'")

    In the criteria statements, always use single quotes (') around text data types and use pound sign (#) around date types. Numeric types require no enclosing characters.

    Best regards,
    Pat Langley

  3. #3
    nick243 is offline Competent Performer
    Windows 7 64bit Access 2002
    Join Date
    May 2016
    Posts
    185
    I put in the new code and checked to varify that in sheet1 it is a text field. I am still getting a Run Time error 3075 Syntax error in date in query expression 'MEF#'.

    Thanks for your help Nick

  4. #4
    PLangley is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Sep 2017
    Location
    Franklin, VA, USA
    Posts
    7
    Since MEF# has a special character in the name, try putting square brackets around it in the lookkup:
    MEFVarX = DLookup("[MEF#]", "Sheet1", "[MEF#] = '" & MEFVar & "'")

    Regards,
    Pat

  5. #5
    nick243 is offline Competent Performer
    Windows 7 64bit Access 2002
    Join Date
    May 2016
    Posts
    185
    It changed the error to
    Run Time error 3075 Syntax error in date in query expression 'MEF# = '183309".

  6. #6
    PLangley is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Sep 2017
    Location
    Franklin, VA, USA
    Posts
    7
    Can you repost your modified code?
    Pat

  7. #7
    nick243 is offline Competent Performer
    Windows 7 64bit Access 2002
    Join Date
    May 2016
    Posts
    185
    Code:
    Private Sub Command39_Click()
    Dim MEFVar, MEFVarX
    
    
    ' Check that the MEF is 6 digits
    MEFVar = InputBox("Enter a MEF Number to start a new Chargeback:", "Open New Chargeback")
    If Len(MEFVar) <> 6 Then
        MsgBox MEFVar & " is not a valid MEF Number."
        End
    End If
    
    
    'Check that MEF is valid
    
    
    MEFVarX = DLookup("[MEF#]", "Sheet1", "MEF# = '" & MEFVar & "'")
    If IsNull(MEFVarX) = True Then
        MEFVarX = MsgBox(MEFVar & " is not found on the list of MEF numbers. " & vbNewLine & vbNewLine & "Do you want to write a Chargeback for this MEF " & MEFVar & "?", 4)
        If MEFVarX <> 6 Then
            End
        End If
    End If
    
    
    
    
    
    
    End Sub

  8. #8
    nick243 is offline Competent Performer
    Windows 7 64bit Access 2002
    Join Date
    May 2016
    Posts
    185
    I got it, I forgot to put [] around Criteria MEF#.

    Thank You for your help

    Nick

  9. #9
    PLangley is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Sep 2017
    Location
    Franklin, VA, USA
    Posts
    7
    Yep, you found it. Glad I could help.

    Best regards,
    Pat Langley

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

Similar Threads

  1. Replies: 2
    Last Post: 01-04-2016, 09:40 AM
  2. Error #: 3075 in DLookup
    By Reaper in forum Programming
    Replies: 2
    Last Post: 08-11-2014, 03:04 PM
  3. Dlookup run-time error '3075'
    By sq75222 in forum Access
    Replies: 5
    Last Post: 08-08-2014, 12:52 PM
  4. DLookup Error 3075
    By healey33 in forum Access
    Replies: 2
    Last Post: 05-21-2013, 10:05 AM
  5. Replies: 5
    Last Post: 09-05-2012, 09:28 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