search criteria

  • Thread starter Thread starter anonymous
  • Start date Start date
A

anonymous

I'm having trouble with a form

On a form I have two unbound cbo boxes controlled by
queries
1) start Month
2) end Month

on a report I have one txt box
1) month

I would like to have the form set up so that when I select a
month in the start and end Month, a corresponding report
will open.

I'm hoping I can do this with a form, instead of in the report
itself because I would like to have several different ways to
search within the report.

Is there a way to do this?
 
forgot to add this...

thought it might help what I'm trying to get across

The closest I can get to what I want to achieve seems to
result in the opposite.
I'm new to this kind of coding.

stLinkCriteria = "occMm = Forms![SearchOccRep2001]!
searchStartMonth And Forms![searchOccRep2001]!
searchEndMonth"
 
The simplest is to add a command button to the form with the two combos. to
create the WhereCondition string argument and use in a DoCmd.OpenReport
statement.

When you add the command button, use the built in Wizard and select Open a
report, the basic code for the buttom will be created for you.

In the code for the button, set the name of the report
strDoccumentName = "MyReport"

and create the WhereCondition string like this:
strWhereCondition = "(MyTable.MyDate >= #" & Me.ComboStartDate & "#) And
"(MyTable.MyDate <= #" & Me.ComboEndDate & "#)"
When the code runs this estring will evaluate to
(MyTable.MyDate >= #2/1/04#) And "(MyTable.MyDate <= #2/29/04#)
and will filter your report to show data only for records wher the field
MyDate is between and including 2/1/04 and 2/29/04.

Ragnar
 
Back
Top