VBA code help
I'm trying to run the following VBA code in MSACCESS to retrieve a field value but the code is returning an error message. The code is as follows:
Private Sub VATType_lostfocus()
Me.Refresh
Set a = CurrentDb.OpenRecordset("select sum(Rate) from VATTyp where VType = " & Me.VATType & "")
The error I'm getting is: Run-Time error 3061. Too few parameters. Expected 1
Kindly help to resolve
-
Official comment
Hello Ali,
What data type is VType? If it's a number, your criteria is okay. If it's text, the value in the criteria needs to be enclosed by quotes.
An easy way to create SQL strings is to create the query in the Access query designer then view the SQL it generates. You can then copy that into your module and substitute the values to change.
Comment actions
Please sign in to leave a comment.
Comments
1 comment