recordset query

  • Thread starter Thread starter Robert Painter
  • Start date Start date
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
 
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
 
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
 
Back
Top