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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering and searching in access using code

Status
Not open for further replies.

AmatuerAtBest

Technical User
Jan 3, 2007
8
US
I am trying to do a search in access. My code is as follows

Private Sub Command348_Click()
Dim sString As double

On Error GoTo Command348_Err
Me.OrderByOn = False
Me.OrderBy = "Invoice #"
Me.OrderByOn = True
Me.FilterOn = False
sString = Me.Text345
Me.Filter = "[Invoice #]= sString"
Me.FilterOn = True
Command348_Exit:
Exit Sub
Command348_Err:
MsgBox Err.Description, vbOKOnly, "Search"
Resume Command348_Exit
End Sub

This however, give me the error of 'you canceled the previous operation'

This code works if Invoice # is a text instead of a number, as I used this code for another search.

Any ideas?
 
What about replacing this:
Me.Filter = "[Invoice #]= sString"
with this ?
Me.Filter = "[Invoice #]=" & sString

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
You may also replace this:
Me.OrderBy = "Invoice #"
with this:
Me.OrderBy = "[Invoice #]"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top