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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 3601

Status
Not open for further replies.

sda7bobp

Technical User
Feb 14, 2005
28
US
I have a table (tblInvUsed) with a field called CaseNum which contains multiple records for one CaseNum. In a Class module from a form (frmCaseEntryDr) I want to open this table and check the set of records with the same CaseNum that is active on the form for certain drugs ordered for a procedure. I have used the following code and have received "Error 3061: Too few parameters: Expected 1"

Code:
Dim db as Database, rst as Recoreset, lngCaseNum as Long
lngCaseNum = Me.CaseNum
strSQL = "SELECT * FROM tblInvUsed [COLOR=red]WHERE '[CaseNum] = ' & lngCaseNum [/color red]"
        Set db = CurrentDb
        Set rst = db.OpenRecordset(strSQL)

Access reads the lngCaseNum correctly in the Debug Window. The strSQL appears to be written just like the help file states, but I must be doing something wrong - I suspect it is in the WHERE statement.

Thanks for your help.
Bob
 
Is your problem witth the way you did you single quotes?
Try this if casenum is numeric:
strSQL = "SELECT * FROM tblInvUsed WHERE [CaseNum] = " & lngCaseNum

Try this if casenum is a string:
strSQL = "SELECT * FROM tblInvUsed WHERE [CaseNum] = '" & lngCaseNum & "'"

Hope it helps!
Matt
 
Thanks, Matt, for replying so quickly. Actually CaseNum is a long number. Trying your solution resulted in a syntax error.
Bob
 
And this ?
strSQL = "SELECT * FROM tblInvUsed WHERE CaseNum=" & lngCaseNum

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Are you sure you typed it in right?

Run this query in Access's:
SELECT * FROM tblInvUsed WHERE CaseNum = (any casenum)
Then just change the casenum you used to lngcasenum when you figure out the syntax error.
You can also get rid of the strsql and do this to see if it works:
Set rst = db.OpenRecordset("SELECT * FROM tblInvUsed WHERE CaseNum = " & lngCaseNum)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top