gopher_by_fende
Registered User.
- Local time
- Today, 10:25
- Joined
- May 21, 2005
- Messages
- 18
Hi,
I am trying to make a search form for a new database, but i am running into problems. When i enter something into the search text box and hit the search button, i get the error -
Runtime Error 2001
You cancelled the previous operation
and it highlights a section of code that at fault -
Option Compare Database
Private Sub btnSearch_Click()
Dim strSearchType As String
Dim strSearch As String
Dim strSQL As String
strSearchType = Me.txtSearchtype
strSearch = Me.txtSearch
'Update the record source
Me.frmsubjobinfo.Form.RecordSource = "SELECT * FROM jobs_query WHERE " & strSearchType & strSearch
'Requery the subform
Me.frmsubjobinfo.Requery
End Sub
Private Sub optSearch_AfterUpdate()
Select Case optSearch.Value
Case 1
txtSearchtype.Value = "Jobno = "
Case 2
txtSearchtype.Value = "quoteno = "
Case 3
txtSearchtype.Value = "custno = "
Case 4
txtSearchtype.Value = "name = "
Case 5
txtSearchtype.Value = "sitename = "
End Select
End Sub
I'm new to VBA so there is probably something obvious to you all that i can't see, but i just can't figure it out.
Any help would be appriciated
Thanks
I am trying to make a search form for a new database, but i am running into problems. When i enter something into the search text box and hit the search button, i get the error -
Runtime Error 2001
You cancelled the previous operation
and it highlights a section of code that at fault -
Option Compare Database
Private Sub btnSearch_Click()
Dim strSearchType As String
Dim strSearch As String
Dim strSQL As String
strSearchType = Me.txtSearchtype
strSearch = Me.txtSearch
'Update the record source
Me.frmsubjobinfo.Form.RecordSource = "SELECT * FROM jobs_query WHERE " & strSearchType & strSearch
'Requery the subform
Me.frmsubjobinfo.Requery
End Sub
Private Sub optSearch_AfterUpdate()
Select Case optSearch.Value
Case 1
txtSearchtype.Value = "Jobno = "
Case 2
txtSearchtype.Value = "quoteno = "
Case 3
txtSearchtype.Value = "custno = "
Case 4
txtSearchtype.Value = "name = "
Case 5
txtSearchtype.Value = "sitename = "
End Select
End Sub
I'm new to VBA so there is probably something obvious to you all that i can't see, but i just can't figure it out.
Any help would be appriciated
Thanks