Unfortunately, when you use the Like *, you may get managers whose names are
similar appear on the same report. You don't have both a "Cho" and a "Chou"
as managers, do you?
What I do in this situation is to create a SQL Where clause string based on
the input parameters, and include it in the OpenReport command.
Thus, something along these lines:
Dim stWhere as String
Dim blNeedAnd as Boolean
blNeedAnd = False
IF len(Me.txtStartDate) > 1 THEN
stWhere = "[DateField] >#" & Me.txtStartDate & "#"
blNeedAnd = True
END IF
IF len(Me.txtEndDate) > 1 THEN
IF blNeedAnd THEN
stWhere = stWhere & " AND "
END IF
stWhere = stWhere & "[DateField] >#" & Me.txtEndDate & "#"
blNeedAnd = True
END IF
IF len(Me.txtManager) > 1 THEN
If blNeedAnd THEN
stWhere = stWhere & " AND "
ENDIF
stWhere = stWhere & "[DateField] >#" & Me.txtEndDate & "#"
blNeedAnd = True
END IF
...etc.
Eventually:
DoCmd.OpenReport "ReportName",,stWhere
(Not sure I have the right number of commas. But that is easy for you to
figure out.)
Hope that helps!
Phil Freihofner
Rick B said:
In the query upon which the report is based, just put something like the
following....
For your date...
Between Forms![MyFormName]![StartDateFieldName] and
Forms![MyFormName]![StopDateFieldName]
For your Manager...
Like Forms![MyFormName]![ManagerFieldName] & "*"
Note: The manger above lets the user leave it blank for all.
For your Branch...
Like Forms![MyFormName]![BranchFieldName] & "*"
Note: The branch above lets the user leave it blank for all.
--
Rick B
Candi via AccessMonster.com said:
I have a series of reports that I need to pull up by date, or by manager or
by branch. The reports are already pre-defined.
I have created a reports panel/form for all reports with a to/from date, and
drop-downs for manager and branch.
But, now I'm stuck on how to make the above parameters work correctly. Do I
create a parm table? I think I need to add the to/from date field to each
report. But, I'm lost after that.
Does anyone have a solution for this?
Thanks,
Candi