BrettM
just a pert, "ex" to come
- Local time
- Today, 21:50
- Joined
- Apr 30, 2008
- Messages
- 134
I have an SQL update query that is performing badly and I was wondering if anyone can give me a pointer please? Is there any issues with using a public variable within an SQL statement?
The following code works perfectly if I remove the reference to PublicVar. Setting a break point I can see that PublicVar does contain the general text string that I desire so I don't believe it is a date format issue etc.
I have split the "SQL=" code for readibility purposes here - it is all one line in my system. The error I am getting is Run-time error 3061 - Too few parameters. Expected 1.
Nothing I have searched on gives me any clue as to why it is happening here. Your assistance would be greatly appreciated.
Regards Brett
The following code works perfectly if I remove the reference to PublicVar. Setting a break point I can see that PublicVar does contain the general text string that I desire so I don't believe it is a date format issue etc.
Code:
Public Sub UpdateExpired()
Dim SQL As String
PublicVar = Format(Date, "dd/mm/yy") & " Voucher marked as expired today."
SQL = "UPDATE Vouchers" & _
"SET Vouchers.Expired = -1, Vouchers.Notes = Vouchers.Notes + Chr$(13) + Chr$(10) & PublicVar" & _
"WHERE (((Vouchers.Expired)=0) AND ((Date())>[Vouchers]![ExpDate]));"
CurrentDb.Execute SQL
PublicVar = ""
End Sub
I have split the "SQL=" code for readibility purposes here - it is all one line in my system. The error I am getting is Run-time error 3061 - Too few parameters. Expected 1.
Nothing I have searched on gives me any clue as to why it is happening here. Your assistance would be greatly appreciated.
Regards Brett