Set criteria (filter) in a subform with command button (1 Viewer)

BukHix

Registered User.
Local time
Today, 10:17
Joined
Feb 21, 2002
Messages
379
I have a subform that shows all the records in my table. I also have an option group representing the 4 quarters of a year. I am trying to filter the data in the subform based on the current selected option.

What is the best way to do this? Here is what I have so far I just need the proper code for setting the "filter" on the subform instead of the OpenForm that is currently in my code.
Code:
Dim strNumb As String

If Me.frmChoose = 1 Then
    strNumb = "1st"
ElseIf Me.frmChoose = 2 Then
    strNumb = "2nd"
ElseIf Me.frmChoose = 3 Then
    strNumb = "3rd"
ElseIf Me.frmChoose = 4 Then
    strNumb = "4th"
End If

' I need to filter the frmSafeIncentSub subform
' with the selected criteria instead of opening
' the form.

DoCmd.openform "frmSafeIncentSub", acNormal, , _
    "[quarter]='" & strNumb & "'"
 

Elana

Registered User.
Local time
Today, 07:17
Joined
Apr 19, 2000
Messages
232
Can you post this database so I can look at what you're trying to do?
 

BukHix

Registered User.
Local time
Today, 10:17
Joined
Feb 21, 2002
Messages
379
Yes thank you Elana. Here is a stripped down demo of what I am trying to do.
 

Attachments

  • demo.zip
    31.9 KB · Views: 121

Elana

Registered User.
Local time
Today, 07:17
Joined
Apr 19, 2000
Messages
232
Okay - so here's what I did.

I changed the Quarter field in your table to be a numeric field. The combo box now has 2 columns.

Then I named the Option Group on your form to "Quarter." I then linked the main form to the subform using the field Quarter.

All the user has to do is select the quarter and the appropriate records display on the subform. No need for a separate button to click.

Take a look and let me know if you have any questions.

HTH
 

Attachments

  • demo.zip
    45.7 KB · Views: 139

BukHix

Registered User.
Local time
Today, 10:17
Joined
Feb 21, 2002
Messages
379
I think that will do the trick. I have to modify a few other things in another table to make it work right but you have definitely put me on the right track. Thanks!
 

Users who are viewing this thread

Top Bottom