none
ERROR 3061 RRS feed

  • Question

  • I'm trying to run a query using SQL at MSaccess. It's very simple but it keeps returning this error: Error 3061- too feew parameter.

    Private Sub btn_pesquisar_Click()

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim sqltext As String

    sqltext = "SELECT * FROM BancoDeDadosClientes WHERE BancoDeDadosClientes.CPF= " & Me.pesquisaPlacaTxt

    Set db = CurrentDb()
    Set rs = db.OpenRecordset(sqltexto)
    End Sub

    I undestand that this error happens a lot when there is a typo in the name of the parameter , but i double checked and there is nothing wrong with the name of the parameter. 

    Thank you very much !!!

    Monday, January 20, 2020 8:29 PM

Answers

  • Is CPF a text field? If so, enclose the value of pesquisaPlacaTxt in single quotes (apostrophes):

    sqltext = "SELECT * FROM BancoDeDadosClientes WHERE BancoDeDadosClientes.CPF='" & Me.pesquisaPlacaTxt & "'"


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by eusepes Monday, January 20, 2020 9:22 PM
    Monday, January 20, 2020 9:08 PM

All replies

  • Is CPF a text field? If so, enclose the value of pesquisaPlacaTxt in single quotes (apostrophes):

    sqltext = "SELECT * FROM BancoDeDadosClientes WHERE BancoDeDadosClientes.CPF='" & Me.pesquisaPlacaTxt & "'"


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by eusepes Monday, January 20, 2020 9:22 PM
    Monday, January 20, 2020 9:08 PM
  • That's right ! Now, its working as it should! Thank you very much for you help !
    Monday, January 20, 2020 9:25 PM