General discussion


MS Access: Run-time error 3061

By jdlp ·
i'm trying to create a form that when you search for a Code number, it populates certain fields!

but everytime i run it i get "Run-time error 3061" "Too few Parameters. Expected 1."

below is the code, however i will require several of these search boxes, one already runs with a pretty similar code, only the variable names and source have been changed.

Private Sub TxtSCode_Exit(Cancel As Integer)
' Enter key was pressed, Lookup the appropriate product code
Dim strSCode As String
Dim StrSSQL As String
Dim rsSProductDetails As Recordset
strSCode = TxtSCode & ""
If strSCode = "" Then
' If Text Box is empty do nothing
Exit Sub
End If
' Otherwise find the appropriate Product Code
StrSSQL = "Select * from refProductCodes where SCode = '" & strSCode & "'"
Set rsSProductDetails = CurrentDb().OpenRecordset(StrSSQL)

If Not rsSProductDetails.EOF Then
'Update the ProductCode field
Me.ProductCode = rsSProductDetails.Fields("ProductCode")
' Update the ProductType field
Me.ProductType = rsSProductDetails.Fields("Type")

MsgBox "Bar Code not found", , "Brita Damages"
End If

' Empty the TextBox

TxtSCode = ""
End Sub

is there something i'm missing !!

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by vohalloran In reply to MS Access: Run-time error ...

I ran this code (with some minor changes to the names of controls) in MS Access 2003 and did not get any errors. This error is listed on the Microsoft website where it says it happens when the sql statement tries to select from a query that has a parameter field. Is refProductCodes a query or a table? If it is a query that requires the user to enter the value of some field, it may be producing the error. I ran the sql statement on a table, not a query.

Hope this helps.

Collapse -

by jdlp In reply to

refProductCodes is a table, what i'm wondering is, is it that i have on the same form, another box doing the same process for a different field of that table. could these two be conflicting and how would i resolve this?

Collapse -

by john.a.wills In reply to MS Access: Run-time error ...

If you click to the left of a VBA line you will get a brown disc and the program will halt at that point. Then you can determine just where the run-time error occurs and putting your cursor over a variable will show you its value, which should be helpful in tracing back the error.

Collapse -

by jdlp In reply to

cheers for that, that debugging tip is very useful, however, checked code and it seems fine!!

My system is now getting very confusing, because it's just decided to work with now changes!! must have been a PC glitch, rather than a system one!!

here's the points for the debug tip!!

cheers anyway!!

Collapse -

by jdlp In reply to MS Access: Run-time error ...

This question was closed by the author

Related Discussions

Related Forums