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

Filter Subform From Option Group--Using If/Then 1

Status
Not open for further replies.

boxboxbox

Technical User
Apr 22, 2003
108
US
I want to filter a subform from an option group on the main form.

Basically, when the Onclick fires for the Option group, I want to enter IfThen statements, so that if OptionGroup = 1, then filter the subform so that the Status field = "For Sale"; if OptionGroup=2, then Filter the Subform so the status field = "For Sale" or "On Hold".

I can't seem to get the right syntax--I've tried Docmd.applyfilter; me.subformname.form.filter; and also the Select/From/Where, though I'm not as familiar with the last.

I don't think I can just have the query for the subform bound to the option group, as two of my optiongroup selections need to show more than one "status"

Any suggestions? Thanks...
 
Hi boxboxbox,

Try this:
Private Sub YourFrame_Click()
Dim intFilter As Integer: intFilter = Me!YourFrame
Select Case intFilter
Case 1
Me!SubFormName.Form.FilterOn = False
Case 2
Me!SubFormName.Form.Filter = "Status = 'For Sale'"
Me!SubFormName.Form.FilterOn = True
Case 3
Me!SubFormName.Form.Filter = "Status = 'For Sale' Or Status = 'On Hold'"
Me!SubFormName.Form.FilterOn = True
Case 4
Me!SubFormName.Form.Filter = "Status = 'On Hold'"
Me!SubFormName.Form.FilterOn = True
End Select
End Sub

For the example:
I have a Frame called YourFrame. Rrename if necessary.
Option 1 is "All" and is the Default Value. Value 1
Option 2 is "For Sale" Value 2
Option 3 is "For Sale or On Hold" Value 3
Option 4 is "On Hold" Value 4

Replace SubFormName with your sub Form name.

Bill
 
Hi Bill,

Thanks very much. It was having to add the subform.form that threw me off, and all the different ways to filter various items.

Filter on!

Thanks again,
Boxboxbox
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top