Right, so those of you who have seen my question in the other thread in the forums (Link here) will have seen the form in which this code is for, all be it a completely different problem.
The problem here is the line coloured Red in the following code. When running it, it stops on the red line and displays the following error:
Im sure there are many other problems later on in the code, but i'll tend to those some other time.
So does anyone have any ideas to what the problem may be?
The problem here is the line coloured Red in the following code. When running it, it stops on the red line and displays the following error:
Runtime error: 3061
Too Few parameters. Expected 1.
Code:
Function ScanBooked()
Dim strSQL As String
Dim BookedRecs As Recordset
Dim AmountVar, MixVar, ExtraVar, PriveOverrideVar As Double
Dim ChargedWaitVar, SundayVar As Boolean
Dim StatusVar As String
'SQL to retreive all bookings from a given customer
strSQL = "SELECT Bookings.Status, Bookings.Mix, Bookings.[Order Amount], Bookings.[Price Override], Bookings.Extras, Bookings.[Charged Wait], Bookings.[Customer Number], Bookings.[Sunday Delivery] " & _
"FROM Customer INNER JOIN (Bookings LEFT JOIN [Completed Orders] ON Bookings.[Order Number] = [Completed Orders].[Order Number]) ON Customer.CardinalisCustomerNumber = Bookings.[Customer Number] " & _
"WHERE (((Bookings.Status)='Booked' Or (Bookings.Status)='Pre-Paid') AND ((Bookings.[Customer Number])=[Forms]![ViewAccount]![CustNum]));"
'Open BookedRecs in Read-Only
[COLOR="Red"]Set BookedRecs = CurrentDb.OpenRecordset(strSQL) ', dbOpenSnapshot)[/COLOR]
If BookedRecs.RecordCount > 0 Then
BookedRecs.MoveFirst
Do While Not BookedRecs.EOF
'Main Code to extract data
AmountVar = DLookup("[Order Amount]", "BookedRecs")
MixVar = DLookup("[Mix]", "BookedRecs")
ExtraVar = DLookup("[Extras]", "BookedRecs")
ChargedWaitVar = DLookup("[Charged Wait]", "BookedRecs")
SundayVar = DLookup("[Sunday Delivery]", "BookedRecs")
StatusVar = DLookup("[Status]", "BookedRecs")
PriveOverrideVar = DLookup("[Price Override]", "BookedRecs")
'Only continue if Status is not 'Cancelled'
If StatusVar <> "Cancelled" Then
'Function to calculate the totals
Call AccountFinanceSubs.Calculate_Total(Amount, Mix, Extra, ChargedWait, PriceOverrideVar, SundayVar)
'Code to add up totals for breakdowns of total unpaid and paid
'If customer has booked and not paid
If StatusVar = "Booked" Then
Form_ViewAccount.UnPaidOpenVar = Form_ViewAccount.UnPaidOpenVar + OrderValueSubs.OrderValueVar
End If
'If customer has booked and paid
If StatusVar = "Pre-Paid" Then
Form_ViewAccount.PaidOpenVar = Form_ViewAccount.PaidOpenVar + OrderValueSubs.OrderValueVar
End If
End If
'Move to the Next Record
BookedRecs.MoveNext
Loop
End If
End Function
Im sure there are many other problems later on in the code, but i'll tend to those some other time.
So does anyone have any ideas to what the problem may be?