securityman
New member
- Local time
- Today, 17:13
- Joined
- Nov 8, 2003
- Messages
- 6
Hello All,
I have a form (frmSearch) with one textbox on it from which I would like to do a search with that one criteria.
I have a FIND button from which I would click and it would Search for the above criteria.
In the OnClick event of the button I am trying to use DoCmd RunSQL. I have set up a variable (SQL) as a string and have placed in that variable an SQL statement. (see below)
I have placed this variable as the argument of the DoCmd (DoCmd RunSQL SQL) but I get an error. The Error says, "The RunSQL action requires an argument consisting of an SQL statement".
I looked in HELP and this is the exact way it was done there (unless I am mistaken).
Could any one tell me what I am doing wrong.
Dim SQL As String
SQL = "SELECT * FROM tblEMPLOYEE " & _
"WHERE tblEMPLOYEE.EmployeeID= '" & [Forms]![frmSearch]!Text1.Value
& "'" & _ (this should be on the line above)
" OR tblEMPLOYEE.LastName = '" & [Forms]![frmSearch]!Text1.Value & "'" & _
" OR tblEMPLOYEE.Pass = '" & [Forms]![frmSearch]!Text1.Value & "'" & _
" OR tblEMPLOYEE.LP1 = '" & [Forms]![frmSearch]!Text1.Value & "'" & _
" OR tblEMPLOYEE.LP2 = '" & [Forms]![frmSearch]!Text1.Value & "'" & _
" OR tblEMPLOYEE.LP3 = '" & [Forms]![frmSearch]!Text1.Value & "'" & _
" OR tblEMPLOYEE.LP4 = '" & [Forms]![frmSearch]!Text1.Value & "'" & _
" OR tblEMPLOYEE.LP5 = '" & [Forms]![frmSearch]!Text1.Value & "';"
DoCmd.RunSQL SQL
Thanks!
Securityman
I have a form (frmSearch) with one textbox on it from which I would like to do a search with that one criteria.
I have a FIND button from which I would click and it would Search for the above criteria.
In the OnClick event of the button I am trying to use DoCmd RunSQL. I have set up a variable (SQL) as a string and have placed in that variable an SQL statement. (see below)
I have placed this variable as the argument of the DoCmd (DoCmd RunSQL SQL) but I get an error. The Error says, "The RunSQL action requires an argument consisting of an SQL statement".
I looked in HELP and this is the exact way it was done there (unless I am mistaken).
Could any one tell me what I am doing wrong.
Dim SQL As String
SQL = "SELECT * FROM tblEMPLOYEE " & _
"WHERE tblEMPLOYEE.EmployeeID= '" & [Forms]![frmSearch]!Text1.Value
& "'" & _ (this should be on the line above)
" OR tblEMPLOYEE.LastName = '" & [Forms]![frmSearch]!Text1.Value & "'" & _
" OR tblEMPLOYEE.Pass = '" & [Forms]![frmSearch]!Text1.Value & "'" & _
" OR tblEMPLOYEE.LP1 = '" & [Forms]![frmSearch]!Text1.Value & "'" & _
" OR tblEMPLOYEE.LP2 = '" & [Forms]![frmSearch]!Text1.Value & "'" & _
" OR tblEMPLOYEE.LP3 = '" & [Forms]![frmSearch]!Text1.Value & "'" & _
" OR tblEMPLOYEE.LP4 = '" & [Forms]![frmSearch]!Text1.Value & "'" & _
" OR tblEMPLOYEE.LP5 = '" & [Forms]![frmSearch]!Text1.Value & "';"
DoCmd.RunSQL SQL
Thanks!
Securityman