Results 1 to 5 of 5
  1. #1
    excellenthelp is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Mar 2014
    Posts
    93

    Auto Populate SQL with Run-Time Error 3464

    Hello Accessers,



    I am attempting to figure how to find and fix the error in the code I created below:

    Code:
    Public Function PopulateACAAddress()Dim stACAName As String
    Dim stCity As String
    Dim stState As String
    Dim stCountry As String
    Dim stSQL As String
    
    
    If IsNull(Screen.ActiveForm.[ACAID].Value) Then
      
        MsgBox "Please select a value for the Certifier Name-Abbreviation drop list. An address can not be obtained if a certifier is not currently selected.", vbCritical
    Else
            
            Dim MyDB As Database, RS As Recordset
            Set MyDB = DBEngine.Workspaces(0).Databases(0)
            
            stNextUser = ""
            stACAName = Screen.ActiveForm.[ACAID].Value
            
            
            stSQL = "SELECT * FROM qrySupport_PopulateACAAddress WHERE [ACAID] = '" & stACAName & '""
            Set RS = MyDB.OpenRecordset(stSQL)     <--- gets highlighted in debugger
            lngRSCount = RS.RecordCount
            
            If lngRSCount <> 0 Then
                RS.MoveFirst
                 If IsNull(Trim(RS.Fields("City").Value)) Then
                    stCity = ""
                 Else
                    stCity = Trim(RS.Fields("City").Value)
                 End If
                 
                 If IsNull(Trim(RS.Fields("State").Value)) Then
                    stState = ""
                 Else
                    stState = Trim(RS.Fields("State").Value)
                 End If
                 
                 If IsNull(Trim(RS.Fields("Country").Value)) Then
                    stCountry = ""
                 Else
                    stCountry = Trim(RS.Fields("Country").Value)
                 End If
                
            End If
            
            With Screen.ActiveForm
                .[City] = stCity
                .[State] = stState
                .[Country] = stCountry
            End With
            
    End If
    End Function
    After clicking on the button to auto populate the textboxes, the error below pops up:
    Run-time error '3464': Data type mismatch in criteria expression.

    I have tried with and without the quotations in this line below:
    Code:
    stSQL = "SELECT * FROM qrySupport_PopulateACAAddress WHERE [ACAID] = '" & stACAName & '""
    What could the issue be?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    There's an error in your code. It would be one of these, depending on whether ACAID is numeric or text:

    stSQL = "SELECT * FROM qrySupport_PopulateACAAddress WHERE [ACAID] = " & stACAName

    stSQL = "SELECT * FROM qrySupport_PopulateACAAddress WHERE [ACAID] = '" & stACAName & "'"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    What is
    qrySupport_PopulateACAAddress

  4. #4
    excellenthelp is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Mar 2014
    Posts
    93
    pbaldy, you got it! It was numeric.

    Thanks!!!

    Marking this as SOLVED.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    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. Execution error 3464
    By Trisha in forum Access
    Replies: 3
    Last Post: 03-03-2014, 01:03 PM
  2. Error 3464 - Data type mismatch
    By JustLearning in forum Forms
    Replies: 1
    Last Post: 01-18-2013, 08:31 PM
  3. Replies: 15
    Last Post: 12-04-2012, 01:39 PM
  4. Run-time error '3464' Date criteria
    By tylerg11 in forum Forms
    Replies: 3
    Last Post: 12-30-2011, 12:34 PM
  5. 3464 error received
    By TEN in forum Programming
    Replies: 10
    Last Post: 07-08-2009, 07:25 PM

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