Run-time error 3061 - Too few parameters. Expected 1

AndyCabbages

Registered User.
Local time
Today, 07:53
Joined
Feb 15, 2010
Messages
74
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
 
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.
 
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]
 
Try this instead of orderNo:

Forms!FormName.orderNo
 
I have actually solved this issue by creating a new report, but doing things slightly differently so this report is no longer needed
 

Users who are viewing this thread

Back
Top Bottom