error 3061

  • Thread starter bullman bullman via AccessMonster.com
  • Start date
B

bullman bullman via AccessMonster.com

I'm trying to add a button that find a record in a table and populates text
boxes on the form. I have a query that sets the criteria equal to the text
I want the record for. My code is:

Dim rst As Recordset
Dim db As Database
Dim strSQL As String

Set db = CurrentDb
strSQL = "SELECT History.Drawing, History.[Total Laser Cutting], History.
[Total Price], History.[Total Discounted Price]FROM History WHERE
History.Drawing=[Enter Drawing #];"

Set rst = db.OpenRecordset(strSQL)
Me.TOTAL_PRICE = rst.Fields("Total Price")
Me.DiscountTotal = rst.Fields("Total Discounted Price")

I'm getting an error message "Run-Time error 3061'. To few parameters.
Expected 1. Can anyone tell me where I've messed up? Thanks.
 
W

Wayne Morgan

Usually, this is caused by a typo in a field name, so Access assumes it is a
parameter since it doesn't recognize the field name. In your rst.Fields
statements, try using brackets around the field names since they have spaces
in them.

Example:
Me.TOTAL_PRICE = rst.Fields("[Total Price]")

In the SQL statement, make sure there is a space before the word FROM. You
have also set the WHERE clause to
History.Drawing=[Enter Drawing #]

What is [Enter Drawing #]? This appears to be a parameter. How is this value
supposed to be supplied? Is there a textbox on the form that has this value?
Are you wanting to prompt the user for this value?

--
Wayne Morgan
MS Access MVP


bullman bullman via AccessMonster.com said:
I'm trying to add a button that find a record in a table and populates
text
boxes on the form. I have a query that sets the criteria equal to the
text
I want the record for. My code is:

Dim rst As Recordset
Dim db As Database
Dim strSQL As String

Set db = CurrentDb
strSQL = "SELECT History.Drawing, History.[Total Laser Cutting], History.
[Total Price], History.[Total Discounted Price]FROM History WHERE
History.Drawing=[Enter Drawing #];"

Set rst = db.OpenRecordset(strSQL)
Me.TOTAL_PRICE = rst.Fields("Total Price")
Me.DiscountTotal = rst.Fields("Total Discounted Price")

I'm getting an error message "Run-Time error 3061'. To few parameters.
Expected 1. Can anyone tell me where I've messed up? Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top