Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ERROR ON SEARCH FORM 1

Status
Not open for further replies.

barry2004

Technical User
Oct 13, 2004
42
GB
Hi guys i have search form on my database which searches for results from a query called qry_searchBK and this query is derived from a table called tbl_bookings. I have a search button on the form which has on OnClick event as seen below. When i click on the search button i get an "Run-time error 2001 you cancelled the previous opertaion" message, it then asks you to Debug or End. If i choose to Debug, it always highlights "Me.FilterOn = True" (second line of coding below), any suggestions?
YOU CAN SEE THE SEARCH FORM & TRY FOR YOURSELF AT:-
------------------------------------------------------
Private Sub Command54_Click()
Me.FilterOn = True

Me.Filter = search1 & " Or " & search2 & " Or " & search3 & " Or " & search4
DoCmd.RunCommand acCmdDatasheetView
DoCmd.MoveSize , , 18100, 6700
End Sub

Function search1()
If IsNull(Lookup1) Or Lookup1 = "" Then
search1 = "[Tag_Number] = 'xxxx'"
Else
search1 = "[Tag_Number] Like '" & Lookup1 & "*'"
End If
End Function


Function search2()
If IsNull(lookup2) Or lookup2 = "" Then
search2 = "[Customer Name] = 'xxxx'"
Else
search2 = "[Customer Name] Like '" & lookup2 & "*'"
End If
End Function

Function search3()
If IsNull(lookup3) Or lookup3 = "" Then
search3 = "[Signed In] = 'xxxx'"
Else
search3 = "[Signed In] Like '" & lookup3 & "*'"
End If
End Function

Function search4()
If IsNull(Lookup4) Or Lookup4 = "" Then
search4 = "[Signed Out] = 'xxxx'"
Else
search4 = "[Signed Out] Like '" & Lookup4 & "*'"
End If

Me.FilterOn = True

Me.Filter = search1 & " Or " & search2 & " Or " & search3 & " Or " & search4

Lookup1 = ""
lookup2 = ""
lookup3 = ""
Lookup4 = ""
End Function
 
Here you are, I have changed these two subs. It is a good thing that it stopped at the first line as search4 would start again at the begining, over and over :)

Code:
Private Sub Command24_Click()
'Move from search 4, consider a Clear button
'Lookup1 = ""
'lookup2 = ""
'Lookup3 = ""
'Lookup4 = ""

strFilter = search1 & " Or " & search2 & " Or " & search3 & " Or " & search4
Me.Filter = """ & strFilter & """
Me.FilterOn = True
DoCmd.RunCommand acCmdDatasheetView
DoCmd.MoveSize , , 18100, 6700
End Sub

Code:
 Function search4()
 If IsNull(Lookup4) Or Lookup4 = "" Then
  search4 = "[Signed Out] = 'xxxx'"
 Else
  search4 = "[Signed Out] Like '" & Lookup4 & "*'"
 End If
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top