Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 3061: Too Few parameters. Expected 1.

Status
Not open for further replies.

Trevoke

Programmer
Jun 6, 2002
1,142
US
This is the code that's troubling me, under Access 97.

Private Sub DueDate_AfterUpdate()
Dim Comp, Batch, Ship, NYStd, NYMass, FillNumber
Dim strSQL As String
Dim rst As Recordset
Dim dbs As Database

strSQL = "SELECT * FROM tblStdPiecesperDay WHERE ProductType = Forms!frm1AddJob!frm1SubMassCode!ProductType;"

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strSQL)
If rst.RecordCount = 0 Then
rst.AddNew
rst!ProductType = Forms!frm1AddJob!frm1SubMassCode!ProductType
rst!StdNumPiecesPerDay = InputBox("No data found related to how many pieces of " & rst!ProductType & " can be filled in a day.", "Inventory Database - no data found.")
rst.Update
End If

FillNumber = rst!StdNumPiecesPerDay

rst.Close
Set rst = dbs.OpenRecordset("tblConfig")
Comp = rst!ComponentsNeededBy
Batch = rst!BatchStartedBy
Ship = rst!ShipDays
NYStd = rst!NYStdDays
NYMass = rst!NYMassDays

rst.Close

End Sub

I get the error message at
Set rst = dbs.openrecordset(strSQL).

The error message is : Run Time error 3061. Too Few parameters. Expected 1.

Does anyone know what's going wrong?

(yes, the form I am referring to to grab ProductType is open at the time the query is made. It's a subform of frm1AddJob, which is open.) Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum immane mittam.
 
Hi!

Change this:

strSQL = "SELECT * FROM tblStdPiecesperDay WHERE ProductType = Forms!frm1AddJob!frm1SubMassCode!ProductType;"

To this:

strSQL = "SELECT * FROM tblStdPiecesperDay WHERE ProductType = '" & Forms!frm1AddJob!frm1SubMassCode!ProductType & "'"

Assuming ProductType is text. If not then leave out the first single quote and the last apersand along with everything after it.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Hi,

Is ProductType a text field if so it shold have single quotes around it in your selection statement. I changed your code to include an intermdeiate variable to save processing tyime and clarity called strProdType.

dim strProdType as string

strProdType = Forms!frm1AddJob!!frm1SubMassCode!ProductType

'Notice the quotes.
strSQL = "SELECT * FROM tblStdPiecesperDay WHERE ProductType='" & strProdType & "';"

Check the NAME property of the subform to esnure it is ProductType not just the controlsource.

I tried your code with my changes and it worked fine.

Have a good one!
BK
 
Indeed, you two were right, that was it. Thanks to both of you :) Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum immane mittam.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top