Access command buttons

J

J B

Does anyone know how to make it so that a command button can be set up in a
form so that when a date is typed into a text box, this date is then used as
a filter by selection to produce a filtered table showing referrals made on
that date.
 
R

rowiga

Assuming that the form contains the date field that you want to filter on you
can do a couple of things.

1. Just have the user right-click in the date field and type in the date
they want to search for.

2. If you have right-clicking disabled for the form, you can run filter by
selection on the appropriate date field using the double-click event on the
field. Whatever date is in the field will be used for the filter.

Private Sub YourDateField_DblClick(Cancel As Integer)
DoCmd.RunCommand acCmdFilterBySelection
End Sub

3. You could use an unbound text box in the header or footer of the form and
use the after update event to filter for the appropriate records.

Private Sub YourUnboundTextBox_AfterUpdate()
DoCmd.OpenForm "YourFormName", acNormal, ,
"Forms![YourFormName]![YourDateField]=[YourTablename].[YourDateField]",
acFormEdit
End Sub
 
F

fredg

Does anyone know how to make it so that a command button can be set up in a
form so that when a date is typed into a text box, this date is then used as
a filter by selection to produce a filtered table showing referrals made on
that date.

Code the Click event of the command button:

Me.Filter = "[DateField] = #" & Me!ControlName & "#"
Me.FilterOn = True
 
Top