Filter on a form true/false/neither

Kassy

Registered User.
Local time
Today, 16:41
Joined
Jan 25, 2006
Messages
66
Is it possible to filter a forms records by using a boolean True/False field.
I want to show all current records for option 1, Expired records for option 2, and all records for option 3. The form is based on 'tblMembers' which has a field [Expired] which is a boolean yes/no field formatted to true/false.
 
Use Select Case with Boolean field

Hi Kasey,

I don't know if you have solved your problem yet, but I have just wrangled an identical problem. Due credit to all the regular forum posters etc.

I have put notation in the code so I don't think you will have any problems following it, but if you do post back.

:)
Code:
Private Sub txt_Toggle_Records_Click()
On Error GoTo Err_Handler

[COLOR="DarkGreen"]'Form opens filtered for All Active records

'txt_Toggle_Records is configured as a pseudo button _
to allow formatting of back colour and caption etc and _
cycles through Current, Active & Archived Projects

'txt_Check_Toggle is an unbound text box with a default value of "0" _
and formatted as hidden (Visible = No)

'Select case checks the contents of txt_Check_Toggle _
and runs the appropriate code

'Archive is a Boolean field in the underlying underlying table _
and is included in the query the form is based on without any _
criteria set.[/COLOR]
    Select Case [txt_Toggle_Count]

'Current records = all records not marked as 'Archive'
    Case "0"
        Me!txt_Toggle_Records.Caption = "Current Projects"
        Me!txt_Toggle_Records.BackColor = 10485760      [COLOR="darkgreen"]'Dark Blue[/COLOR]
        Me.txt_Toggle_Count = "1"             [COLOR="DarkGreen"]'Increment the counter[/COLOR]
        Me.FilterOn = True
        Me.Filter = "[Archive]=No"
        Call Sort_Records
 
[COLOR="darkgreen"]'Archive records = all records marked as 'Archive'[/COLOR]
    Case "1"
        Me!txt_Toggle_Records.Caption = "Archived Projects"
        Me!txt_Toggle_Records.BackColor = 16757657      [COLOR="DarkGreen"]'Light Blue[/COLOR]
        Me.txt_Toggle_Count = "2"      [COLOR="DarkGreen"]'Increment the counter[/COLOR]        
        Me.FilterOn = True
        Me.Filter = "[Archive]=Yes"
        Call Sort_Records
  
[COLOR="darkgreen"]'Active projects = records not marked "Archive" or in Pases: "CA", "CO" or "RA"[/COLOR]
    Case Else             [COLOR="darkgreen"]'If counter in not 0 or 1[/COLOR]
        Me!txt_Toggle_Records.Caption = "Active Projects"
        Me!txt_Toggle_Records.BackColor = 5788922       [COLOR="DarkGreen"]'Red[/COLOR]
        Me.txt_Toggle_Count = "0"    [COLOR="DarkGreen"]'Reset the counter[/COLOR]        
        Call Active_Projects_Filter     [COLOR="DarkGreen"]'Filter that the form opens with[/COLOR]
        Call Sort_Records
  
    End Select

Exit_Here:
    Exit Sub

Err_Handler:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_Here
    
End Sub
Button click effects.
Code:
Private Sub txt_Toggle_Records_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me!txt_Toggle_Records.SpecialEffect = 2 [COLOR="darkgreen"]'Create the button click effect[/COLOR]
End Sub
Code:
Private Sub txt_Toggle_Records_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me!txt_Toggle_Records.SpecialEffect = 1 [COLOR="darkgreen"]'Create the button click effect[/COLOR]
End Sub
 

Users who are viewing this thread

Back
Top Bottom