Filtering/Finding Records

  • Thread starter Thread starter McCoy
  • Start date Start date
M

McCoy

Hi

I have tried to use the followin code to display all records
which meet the user entered criteria for a certain field
___________________________________________________________
Private Sub FindCustomerQuote_Click()
On Error GoTo Err_FindCustomerQuote_Click
Dim CusNo As String, CusCode As Long
CusNo = InputBox("Please Enter Code", "Find Records")
CosCode = Val(CusNo)
Me.Filter = "[CustomerNo]=" & CusCode
Me.FilterOn = True




Exit_FindCustomerQuote_Click:
Exit Sub

Err_FindCustomerQuote_Click:
MsgBox Err.Description
Resume Exit_FindCustomerQuote_Click

End Sub
___________________________________________________________

But keep getting the error:

"You Cancelled the previous Operation"



Can anyone suggest what may be causing this and how to fix this.
 
Just an update, I fixed the "Canceled Problem, their was an
OnApplyFilter event attached to the form. I am still stuck as to how to
recall a group of records based on criteria which contains text and
numbers: ie 8ASD901

Can someone please help with this, it would be much appreciated.

Thankyou
 
If the field contains text and numbers, it must be a Text type field.
Therefore it needs quote marks as delimiters in your filter statement:
Me.Filter = "[CustomerNo] = """ & CusCode & """"
--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

McCoy said:
Just an update, I fixed the "Canceled Problem, their was an
OnApplyFilter event attached to the form. I am still stuck as to how to
recall a group of records based on criteria which contains text and
numbers: ie 8ASD901

Can someone please help with this, it would be much appreciated.

Thankyou
Hi

I have tried to use the followin code to display all records
which meet the user entered criteria for a certain field
___________________________________________________________
Private Sub FindCustomerQuote_Click()
On Error GoTo Err_FindCustomerQuote_Click
Dim CusNo As String, CusCode As Long
CusNo = InputBox("Please Enter Code", "Find Records")
CosCode = Val(CusNo)
Me.Filter = "[CustomerNo]=" & CusCode
Me.FilterOn = True




Exit_FindCustomerQuote_Click:
Exit Sub

Err_FindCustomerQuote_Click:
MsgBox Err.Description
Resume Exit_FindCustomerQuote_Click

End Sub
___________________________________________________________
 
Back
Top