Toggle Button help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to filter a subform using a toggle button. If the button is
pressed I want only the records with the date value not entered (if it is
null then show those records) to be displayed. When the button is not
pressed view all records. I assume you would use the view showallrecords
function.
 
James said:
I would like to filter a subform using a toggle button. If the
button is pressed I want only the records with the date value not
entered (if it is null then show those records) to be displayed.
When the button is not pressed view all records. I assume you would
use the view showallrecords function.

Is the toggle button to be on the main form or on the subform? I'm
guessing it would be on the main form. In that case, you could use
logic like this in the toggle button's AfterUpdate event:

'----- start of example code -----
Private Sub tglNoDates_AfterUpdate()

If Me.tglNoDates = True Then
Me.sfMySubform.Form.Filter = "MyDateField Is Null"
Me.sfMySubform.Form.FilterOn = True
Else
Me.sfMySubform.Form.FilterOn = False
Me.sfMySubform.Form.Filter = vbNullString
End If

End Sub

'----- start of example code -----

You'd have to substitute your own names for "tglNoDates" (the toggle
button), "sfMySubform" (the name of the subform control that displays
the subform), and "MyDateField" (the name of the date field you are
filtering on in the subform's recordsource).
 
thank you

Dirk Goldgar said:
Is the toggle button to be on the main form or on the subform? I'm
guessing it would be on the main form. In that case, you could use
logic like this in the toggle button's AfterUpdate event:

'----- start of example code -----
Private Sub tglNoDates_AfterUpdate()

If Me.tglNoDates = True Then
Me.sfMySubform.Form.Filter = "MyDateField Is Null"
Me.sfMySubform.Form.FilterOn = True
Else
Me.sfMySubform.Form.FilterOn = False
Me.sfMySubform.Form.Filter = vbNullString
End If

End Sub

'----- start of example code -----

You'd have to substitute your own names for "tglNoDates" (the toggle
button), "sfMySubform" (the name of the subform control that displays
the subform), and "MyDateField" (the name of the date field you are
filtering on in the subform's recordsource).

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top