SELECT command syntax error

abdoudiaw

Registered User.
Local time
Yesterday, 21:15
Joined
Sep 13, 2013
Messages
15
Hi,
Please help with this SELECT command:

Dim sqlString As String
Dim rs As DAO.Recordset

sqlString = "SELECT * FROM tblUtilisateurs WHERE (tblUtilisateurs.CodeUtilisateur = Me.txtCodeUtilisateur AND tblUtilisateurs.MotDePasse = Me.txtMotDePasse);"
Set rs = CurrentDb.OpenRecordset(sqlString)

Error Message : "Execution error 3061: too few parameters. 3 expected."

Thanks.
 
Just guessing, try:
sqlString = "SELECT * FROM tblUtilisateurs WHERE (tblUtilisateurs.CodeUtilisateur =" & Me.txtCodeUtilisateur & " AND tblUtilisateurs.MotDePasse =" & Me.txtMotDePasse & ");"
If txtCodeUtilisateur or txtMotDePasse are NOT numeric you may need:
sqlString = "SELECT * FROM tblUtilisateurs WHERE (tblUtilisateurs.CodeUtilisateur ='" & Me.txtCodeUtilisateur & "' AND tblUtilisateurs.MotDePasse ='" & Me.txtMotDePasse & "');"
 
Thanks Bob,
This looks better but the instruction
Set rs = CurrentDb.OpenRecordset(sqlString)
is still not happy: "too few parameters. Expecting 1"
Yes txtCodeUtilisateur, txtMotDePasse are text strings.
Thanks.
 
Perhaps you could step through the code at run time and check if either txtCodeUtilisateur or txtMotDePasse are null or ZLS.
 
Thanks Guys,
I found out: one field was misspelled.
Thanks a lot.
 

Users who are viewing this thread

Back
Top Bottom