L
Leonard Priestley
I have designed a form for previewing reports. It has a combo box for
selecting the report, a combo box for selecting the person whose data I
want, and two text boxes to enable me to specify the start and end dates for
the data.
I am writing code to construct a strWhereClause to use with
'DoCmd.OpenReport'. My intention is to use the BuildCriteria Method to
construct a clause that specifies the person, and the Start and End dates.
When I open my report form directly and use it with the code below it works
fine.
strWhereClause = "(" & BuildCriteria("PersonID", dbLong,
frmReport.cboStaffMember) & ")"
strWhereClause = strWhereClause & " AND " & "(" & BuildCriteria("Date",
dbDate, ">= frmReport.txtStartDate") & ")"
strWhereClause = strWhereClause & " AND " & "(" & BuildCriteria("Date",
dbDate, "=< frmReport.txtEndDate") & ")"
However, the next step (which is giving me problems) is that I want to use a
main form to host several forms, including the report form. They are all
treated as source objects for a subform (which I have called
IntroPanel_child) on the main form . This means I have to extend the syntax
when I access the report form from the main form.
So far I have this:
strWhereClause = "(" & BuildCriteria)"PersonID", dbLong,
Forms![frmMain]![IntroPanel_child]. _
frmReport.cboStaffMember) & ")"
strWhereClause = strWhereClause & " AND " & "(" & BuildCriteria("Date",
dbDate, ">= Forms! _
[frmMain]![IntroPanel_child].frmReport.txtStartDate") & ")"
strWhereClause = strWhereClause & " AND " & "(" & BuildCriteria("Date",
dbDate, "=<Forms! _
[frmMain]![IntroPanel_child].frmReport.txtEndDate") & ")"
Whether I access the report form directly, or via the main form, I get boxes
requesting I enter a parameter value. If I try to do this for the dates, I
get a message saying "Expression typed incorrectly, or is too complex to be
evaluated". These Messages only appear after I press the 'preview' command
button.
If I comment out the statements relating to date, and retain only the first
part, specifying the staff member, the code works OK.
I would appreciate some help on this. It's drivng me nuts.
Leonard Priestley
selecting the report, a combo box for selecting the person whose data I
want, and two text boxes to enable me to specify the start and end dates for
the data.
I am writing code to construct a strWhereClause to use with
'DoCmd.OpenReport'. My intention is to use the BuildCriteria Method to
construct a clause that specifies the person, and the Start and End dates.
When I open my report form directly and use it with the code below it works
fine.
strWhereClause = "(" & BuildCriteria("PersonID", dbLong,
frmReport.cboStaffMember) & ")"
strWhereClause = strWhereClause & " AND " & "(" & BuildCriteria("Date",
dbDate, ">= frmReport.txtStartDate") & ")"
strWhereClause = strWhereClause & " AND " & "(" & BuildCriteria("Date",
dbDate, "=< frmReport.txtEndDate") & ")"
However, the next step (which is giving me problems) is that I want to use a
main form to host several forms, including the report form. They are all
treated as source objects for a subform (which I have called
IntroPanel_child) on the main form . This means I have to extend the syntax
when I access the report form from the main form.
So far I have this:
strWhereClause = "(" & BuildCriteria)"PersonID", dbLong,
Forms![frmMain]![IntroPanel_child]. _
frmReport.cboStaffMember) & ")"
strWhereClause = strWhereClause & " AND " & "(" & BuildCriteria("Date",
dbDate, ">= Forms! _
[frmMain]![IntroPanel_child].frmReport.txtStartDate") & ")"
strWhereClause = strWhereClause & " AND " & "(" & BuildCriteria("Date",
dbDate, "=<Forms! _
[frmMain]![IntroPanel_child].frmReport.txtEndDate") & ")"
Whether I access the report form directly, or via the main form, I get boxes
requesting I enter a parameter value. If I try to do this for the dates, I
get a message saying "Expression typed incorrectly, or is too complex to be
evaluated". These Messages only appear after I press the 'preview' command
button.
If I comment out the statements relating to date, and retain only the first
part, specifying the staff member, the code works OK.
I would appreciate some help on this. It's drivng me nuts.
Leonard Priestley