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

USE COMBO FOR FILTER BY SELECTION

Status
Not open for further replies.

damienwjking

Programmer
Jul 11, 2002
26
GB
I am trying to use a number of dropdown combo boxes for the user to use a selection filter. I have used the following code but it produces a run time error saying that the "Filterbyselection isn't available now". Anyone know where im going wrong?????????????

Private Sub ComboSelection_Change()
Screen.ActiveControl.SetFocus
RunCommand acCmdFilterBySelection
End Sub

thanks
 
acCmdFilterBySelection may not work the way you want. Do the comboboxes contain filter strings or just the criteria for a particular field. If they contain the full filter string:
Me.Filter = <combobox>
Me.Requery
If they contain only the criteria:
Me.Filter = &quot;<field name> = '&quot; & <criteria> & &quot;'&quot;
Me.Requery
 
Hmmmm, I have been having trouble trying to apply your help. I tried putting this code on the on change event of the combo

Me.Filter = [Company] = cboCompany.Value
Me.FilterOn = True

I have the combo on the form and then a sub form with the list on contacts that i would like to filter by Company.
When I change the combo all the records disapear even though i have check that the cboCompany.Value is correct.
If I select another value in the combo it say invalid use of &quot;null&quot;

Do I have to set up the Filter to begin with as i have just been using the

Screen.ActiveControl.SetFocus
RunCommand acCmdFilterBySelection

Commands previously on this form. Or is it some other linking i need to do???

Thanks for ur help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top