Forms

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

Guest

I am trying to create a form that has this: From Date and To Date. That
part is easy however, how do I make it work so that it will bring up the
records between those dates in a report. I know you can do it in a query,
but many users are not familiar with a query and I think this would be easier
if they could just plug in the dates and then get the information they need
without all the mess.
 
You can set the Filter property of your form to a string that is based on
the dates in the 2 text boxes.

The string you need to create is identical to one described in Method 2 in
this link:
http://allenbrowne.com/casu-08.html
Although that link is about reports, you build strWhere in exactly the same
way, and then set the form's filter like this:
Me.Filter = strWhere
Me.FilterOn = True
 
I have found it easier to create a form, we'll call it report, that has two
control boxes named 'from date' and 'to date' and a command button that opens
the report(you can use the wizard and set the button to preview report).
Then have the query that is the source for the report have under the date
criteria box the following "between [forms]![report]![from date] and
[forms]![report]![to date]".
Then when they click the preview report button it comes up without any
dialog boxes.

And the user will never have to see any ugly dialog boxes.
 
I am having trouble with the info you gave me on the website:
Else 'Both start and end dates.
strWhere = strField & " Between " & Format(Me.textStartDate,
conDateFormat) _
& " And " & Format(Me.textEndDate, conDateFormat)
When I get the error message it highlights this above.
I keep getting an error message: Syntax Error (missing operator) in query
expression, (Date of Visit Between Date of Visit #01/01/2005#And#07/01/2005#)

What am I not seeing?
 
If the field name contains spaces, you must enclose it in square brackets.
strField = "[Date of Visit]"

You seem to have the Date Of Visit repeated in that string as well. It
should not appear again after Between.

Also, include the spaces around the And.
 
Back
Top