recordset query

R

Robert Painter

Hi
I am trying to run a series of searches on my db and get runtime error
'3061' Too few parameters. expected 1 when i run the following code:


Private Sub cmdOkbutton_Click()
' //----------------------//
' //search for candidates//
' //search for candidates//
' ---------------------//
Dim rs As DAO.Recordset
Dim mySql As String

'/ Create your recordset...

mySql = "SELECT tblEmployees.EmployeeName AS mySearchrs"
mySql = mySql & " FROM tblEmployees LEFT JOIN tblEmployeeSkills ON
tblEmployees.EmployeeID = tblEmployeeSkills.EmployeeIDFK"
mySql = mySql & " WHERE tblEmployeeSkills!SkillIDFK =
Forms!frmcboSearch!cboSearch;"
Set rs = CurrentDb.OpenRecordset(mySql)

MsgBox "mySearchrs"
'/ Close shop..
rs.Close
Set rs = Nothing
End Sub

Can anyone point me in the right direction please ??

Robert
 
A

Allen Browne

Concatenate the value from the combo into the string, e.g.:

mySql = "SELECT tblEmployees.EmployeeName AS mySearchrs " & _
"FROM tblEmployees LEFT JOIN tblEmployeeSkills " & _
"ON tblEmployees.EmployeeID = tblEmployeeSkills.EmployeeIDFK " & _
"WHERE tblEmployeeSkills!SkillIDFK = " & Forms!frmcboSearch!cboSearch & ";"

If SkillIDFK is a Text field (not a Number type when you open your table in
design view), you need extra quotes:
http://allenbrowne.com/casu-17.html
 
R

Robert Painter

Thanx Allen worked a treat

robert


Allen Browne said:
Concatenate the value from the combo into the string, e.g.:

mySql = "SELECT tblEmployees.EmployeeName AS mySearchrs " & _
"FROM tblEmployees LEFT JOIN tblEmployeeSkills " & _
"ON tblEmployees.EmployeeID = tblEmployeeSkills.EmployeeIDFK " & _
"WHERE tblEmployeeSkills!SkillIDFK = " & Forms!frmcboSearch!cboSearch &
";"

If SkillIDFK is a Text field (not a Number type when you open your table
in design view), you need extra quotes:
http://allenbrowne.com/casu-17.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top