Filtering a Form Based on Option Group Selection (1 Viewer)

JamesJoey

Registered User.
Local time
Today, 13:14
Joined
Dec 6, 2010
Messages
608
I'm using the following code:

Code:
Private Sub frmReminderFilter_Click()

Dim strFilter As String
    
    Select Case Filter
        
        Case 1 'All records
            strFilter = "SELECT * FROM tblReminders ORDER BY ReminderDate, ReminderTypeID, ReminderTime, Reminder;"
        Case 2 'ReminderTypeID is 1 (Calendar Event)
            strFilter = "SELECT * FROM tblReminders WHERE [ReminderTypeID]= 1 ORDER BY ReminderDate, ReminderTypeID, ReminderTime, Reminder;"
        
    End Select
    
    Me.RecordSource = strFilter
    Me.Requery

End Sub
I have 2 more Cases to add but I'm having trouble getting this to work.
The default is 1 (All)
I've tried this in the OnClick and AfterUpdate of the OptionGroupe.
When I click 2 (Calendar Event) O get the dreaded #Name?

Not sure where the error is.

James
 

JamesJoey

Registered User.
Local time
Today, 13:14
Joined
Dec 6, 2010
Messages
608
I found it.
In the Select Case I needed to put the Option Group name.

Seems ok now.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 13:14
Joined
Feb 19, 2002
Messages
42,971
Yes, it should be:

Select Case Me.frmReminderFilter
 

JamesJoey

Registered User.
Local time
Today, 13:14
Joined
Dec 6, 2010
Messages
608
Actually I changes the prefix to 'opt' because I'm using 'frm' for my forms name prefix.
 

Users who are viewing this thread

Top Bottom