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

Filter records from combo box selection 1

Status
Not open for further replies.

jw5107

Technical User
Jan 20, 2004
294
US
I have a combo box on a form that has a value list like:
757
767
747

Once the user selects - say 757 from the combo box, I would like see all records pertaining to the 757 fleet on the form. The form is bound back to a table.

Any code ideas???

Thanks in advance!!
jw5107
 
since the form is bound to a table you could use something like this:
Code:
Private Sub Combo30_AfterUpdate()
Filter = "[YOUR FIELD_NAME_HERE] = " & Combo30
FilterOn = True
End Sub

but if you want to remove the filter you'd need another button that just says FilterOn = False

Hope this helps, Jamie
 
Put this in the AfterUpdate (à gusto the Change) event of the combo:
Code:
Me.Filter="field=" Me!ComboBox
Me.FilterOn=True

You could extend it by:
Code:
If len(Me!ComboBox)>0 Then
Me.Filter="field=" Me!ComboBox
Me.FilterOn=True
Else
Me.FilterOn=False
Endif

in order to reset your form to "no filter".

Cheers,
Andy



[blue]The last voice we will hear before the world explodes will be that of an expert saying:
"This is technically impossible!" - Sir Peter Ustinov[/blue]
andreas.galambos@bowneglobal.de
HP:
 
MakeitSo,

I am trying to use your example...

I keep getting an error message - Expected end statement, and this is highlighted in red:
Me.Filter = "FLEET=" Me!FleetSelect

Any fixes?

Thanks for your help.
jw5107
 
Hi, you need to add an & like this...
Me.Filter = "FLEET=" & Me!FleetSelect
 
jksmi,

I tried that and I keep getting a message that tells:
"You cancelled previous operation" and it highlights:
Me.Filter = "FLEET=" & Me!FleetSelect on debug.

Any other fixes...

Thanks!!
jw5107
 
Try something like this:
Me.Filter = "FLEET=[highlight]'[/highlight]" & Me!FleetSelect [highlight]& "'"[/highlight]

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Hi, PH is quite right, I assumed it was a number field, if its a text field then you need to surround the combobox value with 's as per PH else it causes a datatype confict
 
PHV,

I have tried your changes.
When a value is selected from the combobox, the form goes completely null. The filter is on, but the form is null unitl I click the filter off.

Any fixes??

thanks for the help!!
jw5107
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top