View Full Version : Run-time error 3061 - Too few parameters. Expected 1


AndyCabbages
06-05-2010, 07:03 AM
I am working on a report and I am getting a run time error 3061 whenever I try and print off the report. The debugger says the error is in the code below but I cant figure out what is causing it

Dim TableRecords As DAO.Recordset
Dim consumableSQL As String
consumableSQL = "SELECT Hired.Record_number, Hired.Consumable_No, Consumables.Name, Consumables.Description, Hired.Quantity, Hired.[Unit Cost], Hired.Cost FROM Consumables INNER JOIN Hired ON Consumables.Consumable_No = Hired.Consumable_No WHERE (((Hired.Record_number)=" & orderNo & "))"
Set TableRecords = dbsThisDatabase.OpenRecordset(consumableSQL)
If TableRecords.RecordCount = 0 Then
GroupFooter0.Visible = False
subTotal.ControlSource = "=([runningtotal])"
End If

pbaldy
06-05-2010, 08:18 AM
What event is the code in? Where does the value orderNo come from? The error implies that either that value isn't there or one of the field names in the SQL is wrong.

AndyCabbages
06-06-2010, 07:34 AM
The code is in the 'Private Sub Report_Open(Cancel As Integer)' part.

OrderNo comes from a textbox in the form, which contains the value: [Order.QuoteNumber]

pbaldy
06-06-2010, 07:54 AM
Try this instead of orderNo:

Forms!FormName.orderNo

AndyCabbages
06-06-2010, 08:26 AM
I have actually solved this issue by creating a new report, but doing things slightly differently so this report is no longer needed