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

Filtering Records on a Form 2

Status
Not open for further replies.

primagic

IS-IT--Management
Jul 24, 2008
476
GB
I am trying to filter the records on a form by using a listbox

I have a listbox which when a record is selected is populates the select key field to a textbox

I then have the following code to apply the filter but I am getting a data type mismatch error

Code:
DoCmd.ApplyFilter , "ID = '" & txtSelectedRecord & "'"
Me.FilterOn = True
 
Your ID column might be numerical type.

"ID = " & txtSelectedRecord

or

"ID = " & Cint(txtSelectedRecord)

will do it

Zameer Abdulla
 
How are ya primagic . . .

Try
Code:
[blue]   Me.FilterOn = False
   Me.Filter = "ID = " & Me.[purple][B][I]YourListBoxName[/I][/B][/purple].Column(0)
   Me.FilterOn = True[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top