none
Recordset.open gives error "No value given for one or more required parameters." RRS feed

  • Question

  • I have an Microsoft Access 2016 table called Field Parts with 8 columns: ID, Point, Description, Manufacturer, Part Number, Vendor, List Price, Notes. I have a form that asks for a input ID number from the user and open the specific row of data in the table using the recordset.open method.

    I keep getting a run-time error says "No value given for one or more required parameters." 

    The following is my code:

    Private Sub Generate_Click()

    Dim dataPointer As ADODB.Recordset
    Set dataPointer = New ADODB.Recordset

    dataPointer.Open ("Select *" & _
    "From [Field Parts] " & _
    "Where ([Field Parts].[ID] = nbrPartID)")

    End Sub

    nbrPartID is the name of the text box in the form that asks for the user input. I changed nbrPartID to 2 and it works fine. I assume there is something wrong with the nbrPartID.

    This is my first time asking question, please do let me know if I am being unclear. Any help would be greatly appreciated. Thank you very much.

    Tuesday, February 6, 2018 2:27 PM

Answers

  • The value of the text box should be outside the quotes:

    dataPointer.Open "Select * From [Field Parts] Where [ID] = " & Me.nbrPartID


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

    • Marked as answer by wrenhh Tuesday, February 6, 2018 2:55 PM
    Tuesday, February 6, 2018 2:32 PM

All replies

  • The value of the text box should be outside the quotes:

    dataPointer.Open "Select * From [Field Parts] Where [ID] = " & Me.nbrPartID


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

    • Marked as answer by wrenhh Tuesday, February 6, 2018 2:55 PM
    Tuesday, February 6, 2018 2:32 PM
  • Thank you so much, that fix the problem.
    Tuesday, February 6, 2018 2:55 PM