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

Before submitting this, I did read

Status
Not open for further replies.

bostonfrog

Programmer
Jul 14, 2003
79
MX
Before submitting this, I did read other posts regarding this run-time error but didn't find the answer.
It's a simple DAO Recordset (Dim Rs as DAO.Recordset), and I get this error, saying there are TOO MANY PARAMETERS, Expected 1 -- and no help available on the subject.

Code:
strSQL = "SELECT PATIENT.ID FROM tblPATIENTS "
strSQL = strSQL & "WHERE PATIENT.ID = Forms!MyForm!txtID;"
Set rs = Currentdb.OpenRecordset(strSQL)

On this error, the Set rs = line of code is highlighted in yellow and rs = nothing is the tip when I click on the error. Any advice, DAO experts?
 
why couldn't you just say...

strSQL = "SELECT PATIENT.ID FROM tblPATIENTS WHERE PATIENT.ID = Forms!MyForm!txtID"
Set rs = Currentdb.OpenRecordset(strSQL)
 
Take "Forms!MyForm!txtID" out of the quotes:


strSQL = "SELECT PATIENT.ID FROM tblPATIENTS "
strSQL = strSQL & "WHERE PATIENT.ID =" & Forms!MyForm!txtID
Set rs = Currentdb.OpenRecordset(strSQL)

If txtID is not numeric then:

strSQL = "SELECT PATIENT.ID FROM tblPATIENTS "
strSQL = strSQL & "WHERE PATIENT.ID ='" & Forms!MyForm!txtID & "'"
Set rs = Currentdb.OpenRecordset(strSQL)

TwoOdd
--------------
Good judgment comes from experience, and experience comes from bad judgment.
-- Barry LePatner
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top