Filter Form Data

rodneyb

Registered User.
Local time
Today, 20:57
Joined
Jul 3, 2003
Messages
84
I want to create a form which basically just shows the contents of an existing table. However I require two text boxes "Date From" and "Date To" so that the user can enter values into these fields and the form will filter the displayed table based on these values.
 
First create a query and specify in the criteria "Between [Forms]![yourformname]![Date To] And [Forms]![yourform]![Date From]".

Then create a popup form that has Date From and Date To text boxes for entry. Create a command button on the popup form to run the query. Enter the To and From dates in the text boxes and press the command button and the query will run with the dates you specified.
 
I would also add that you should set an input mask to ensure that the user keys a date in the correct format mm/dd/yyyy and also trap for zero records or else the form will appear blank.

sample input mask...
00/00/0000;0;#

Some code to test if the form's record set has zero records...
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "There are zero records in the data source!", vbInformation, "No Records Found"
'do something here to prevent the queried null set from becoming the forms current record set
End If


HTH
 
Auto, I would have gone in design view of the form and put a parameter in that way. But it sounds like the pop up form would allow you to give more information concerning the parameter. Is this why the pop up?
 

Users who are viewing this thread

Back
Top Bottom