Access command buttons

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

Guest

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

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

Back
Top