View Full Version : need help with VBA / MSACCESS code
aazain
10-17-2017, 02:47 AM
I'm trying to retireve a value from Access table using the following code:
Private Sub VATType_lostfocus()
Me.Refresh
Set a = CurrentDb.OpenRecordset("select sum([Rate]) from VATTyp where [VType] = " & Me.VATType & "")
End Sub
But I get the following error: Run-Time error 3061. Too few parameters. Expected 1
Please help to resolve.
Is that the total fo your code?
As there are no dim statements and no error trapping.
Is this recordset based on a query?
Are the field names spelt correctly?
An example database with a small amount of dummy data would be very helpful.
aazain
10-17-2017, 06:00 AM
Is that the total fo your code?
As there are no dim statements and no error trapping.
Is this recordset based on a query?
Are the field names spelt correctly?
An example database with a small amount of dummy data would be very helpful.
yes this is the total code
is the dim statement required?
recordset is based on table
field names are spelled correctly.
Well, Variables and Objects should always be Dimensioned to tell the Access VBA what to expect when they are used.
On top of that you should also be using Error trapping to ensure that errors are reproted correctly and stop you get in an error loop.
So can you explain what you are going to use this value for when you get it?
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.