Toggle Button help

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.
 
D

Dirk Goldgar

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).
 
G

Guest

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Toggle Button Not Displayed Right 1
Toggle button 1
Blank form when no records 1
toggle button nightmare 3
Toggle Button 5
Toggle Button Display? 1
toggle button 7
ApplyType is always 1 for Toggle Filter 0

Top