T
Tony Vrolyk
I am receving the '3061 Too Few Paramters expected 1' error when trying to
run an append query from code. This code is run OnClick of a command button
on a form. The referenced control is on the same form and not null. I have
added debug.print line to show the SQL statement the results of which I then
paste into the SQL view of a test query and it runs fine from there. I don't
understand why this is coming up. Below is the code. I would appreciate any
suggestions.
Thanks
Tony
Private Sub cmdSearch_Click()
'On Error GoTo HandleErr
If Not IsNull(Me.txPayrollDate) Then
Dim db As DAO.Database, strSql As String
Set db = CurrentDb()
strSql = "INSERT INTO Placements_Payrolls ( Placement_ID, PayrollDate )
" _
& "SELECT Placements.Placement_ID, #" & Me.txPayrollDate & "# AS
PayrollDate " _
& "FROM Placements LEFT JOIN qry_Payrolls_ListByDate ON
Placements.Placement_ID = qry_Payrolls_ListByDate.Placement_ID " _
& "WHERE (((Placements.StartDate)<=#" & Me.txPayrollDate & "#) AND
((Placements.EndDate)>=#" & Me.txPayrollDate & "# Or (Placements.EndDate) Is
Null) AND ((qry_Payrolls_ListByDate.Placement_ID) Is Null))"
'The results of this debug work find in the query builder window
Debug.Print strSql
'The error occurs on this line
db.Execute strSql
End If
End Sub
run an append query from code. This code is run OnClick of a command button
on a form. The referenced control is on the same form and not null. I have
added debug.print line to show the SQL statement the results of which I then
paste into the SQL view of a test query and it runs fine from there. I don't
understand why this is coming up. Below is the code. I would appreciate any
suggestions.
Thanks
Tony
Private Sub cmdSearch_Click()
'On Error GoTo HandleErr
If Not IsNull(Me.txPayrollDate) Then
Dim db As DAO.Database, strSql As String
Set db = CurrentDb()
strSql = "INSERT INTO Placements_Payrolls ( Placement_ID, PayrollDate )
" _
& "SELECT Placements.Placement_ID, #" & Me.txPayrollDate & "# AS
PayrollDate " _
& "FROM Placements LEFT JOIN qry_Payrolls_ListByDate ON
Placements.Placement_ID = qry_Payrolls_ListByDate.Placement_ID " _
& "WHERE (((Placements.StartDate)<=#" & Me.txPayrollDate & "#) AND
((Placements.EndDate)>=#" & Me.txPayrollDate & "# Or (Placements.EndDate) Is
Null) AND ((qry_Payrolls_ListByDate.Placement_ID) Is Null))"
'The results of this debug work find in the query builder window
Debug.Print strSql
'The error occurs on this line
db.Execute strSql
End If
End Sub