Not quite
When I open the report a form automatically pops up asking for the
parameters. I must enter them and hit ok prior to the form opening. I have
put a cancel button on this form so that if the report is mistakenly openned
the user does not have to go through the parameter entry and then have the
form load up. however when the button is clicked that is when i get the
message. How can i stop the open event of the report by clicking the cancel
button on my form?
:
you're welcome, Mike
"i got it to work"
I'll bet you are proud of yourself, great!
"(on the form i have an exit button to cancel the operation)"
what do you mean? you click a Cancel button (to close the menu form?)
after you open the report?
If you do not want to leave the report menu form open, then change:
Me.Year_1.ControlSource = [Forms]![WP-112 Summary Reports]![Year 1]
Me.Year_2.ControlSource = [Forms]![WP-112 Summary Reports]![Year 2]
Me.Year_3.ControlSource = [Forms]![WP-112 Summary Reports]![Year 3]
Me.Year_4.ControlSource = [Forms]![WP-112 Summary Reports]![Year 4]
Me.Year_5.ControlSource = [Forms]![WP-112 Summary Reports]![Year 5]
to:
Me.Year_1 = [Forms]![WP-112 Summary Reports]![Year 1]
Me.Year_2 = [Forms]![WP-112 Summary Reports]![Year 2]
Me.Year_3 = [Forms]![WP-112 Summary Reports]![Year 3]
Me.Year_4 = [Forms]![WP-112 Summary Reports]![Year 4]
Me.Year_5 = [Forms]![WP-112 Summary Reports]![Year 5]
so, instead of setting the ControlSource to a form you intend to close,
just set the initial value... then you can close your menu form while
the report is open.
Warm Regards,
Crystal
*
have an awesome day
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
Mike wrote:
First of I would like to say thank you for all ur help so far.
I really didn't understand what youve said (im kind of a newbie to access)
but by playing around with the codes i got it to work. I have my crosstab
query that i entered column headers from 1900 to 2100. I made 5 unbound
fields in my report named Year 1, Year 2 etc
in the open event I used the following:
----
Private Sub Report_Open(Cancel As Integer)
' Set public variable to true to indicate that the report
' is in the Open event
bInReportOpenEvent = True
' Open BEPA Reports Form
DoCmd.OpenForm "WP-112 Summary Reports", , , , , acDialog
' Cancel Report if User Clicked the Cancel Button
If IsLoaded("WP-112 Summary Reports") = False Then Cancel = True
' Set public variable to false to indicate that the
' Open event is completed
bInReportOpenEvent = False
Me.Year_1.ControlSource = [Forms]![WP-112 Summary Reports]![Year 1]
Me.Year_2.ControlSource = [Forms]![WP-112 Summary Reports]![Year 2]
Me.Year_3.ControlSource = [Forms]![WP-112 Summary Reports]![Year 3]
Me.Year_4.ControlSource = [Forms]![WP-112 Summary Reports]![Year 4]
Me.Year_5.ControlSource = [Forms]![WP-112 Summary Reports]![Year 5]
End Sub
----
This allowed my report, whos record source is the crosstab query, to use the
5 years that i selected on my form and use them as column headers in the
report (it will only work for years 1900 to 2100. but thats ok)
The only problem i still have is as follows: say i open the report. on open
the form pops up. (on the form i have an exit button to cancel the
operation). if i hit the exit button i get the following error: Microsoft
Office Access can't find the form "WP-112 Summary Reports" reffered to in a
marco or Visual Basic code.
It seems that its still running the code even though i exitted out of the
form how can i have the code stop if the exit button is pressed.
:
Hi Mike,
Good! You have a form (called ReportMenu?) with 5 comboboxes... we will
put this on hold now and use this later. Perhaps it would be best to
focus on the reports first -- make a subreport in one column and
hardcode in the value of the link until that works -- then we will add
columns and then add code...
correction: subReport_formname should have been subReportName
'~~~~~~~~~~~`
The next step is to make ONE report that will be used as a subreport in
one of the "columns" of your main report
in this report, use the report header but make VISIBLE=No (after you
test it). In this section, be sure to put the fiscal year field as well
as any other fields you want to use to link to the main report. To ease
confusion, open the property sheet and make the NAME property the same
as the ControlSource property for the linking control(s).
For reference, I will call the linking control for fiscal year:
FY_controlname
Make the width of the report the same as the width of a "column" on your
main report.
save this report (which I am referring to as subReportName -- so you
will have to substitute the name you actually give it (don't use spaces
or special characters except the underscore when you name it)
'~~~~~~~~~~~
Now, go to design view of the Main Report
make an unbound textbox control to hold the fiscal year for the
subreport in the first column
Name --> Y1
Visible --> No (change after testing)
ControlSource --> = 2006
(or use another value for the control source, I don't know what you data
is -- once you get the hardcoded values to work, we will work with you
on the code to make them variable)
make a subreport control for the first column
ControlSource --> subReportName
Name --> subReport1
LinkMasterfields --> Y1
LinkChildFields --> FY_controlname
'~~~~~~~~~~~`
try this and let us know if it is successful!
Warm Regards,
Crystal
*
have an awesome day
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
Mike wrote:
Im a little lost still
I made the form as you said with 5 unbound columns named Y1 to Y5
I don't get the next part
ReportMenu subreports:
ControlSource --> subReport_formname
Name --> subReport1
LinkMasterfields --> Y1
LinkChildFields --> FiscalYear_controlname
etc
Thanks for all the help.
:
Hi Mike,
If you were just reporting from the crosstab, it would be easy...
your column headers come from this line:
PIVOT [Capital Job Database].[Scheduled Fiscal Year] In
(1900,2006,2007,2008,2009,2010)
and they would change as your query did... but translating those changes
to a report requires a few more steps...
I am assuming, in your sample data, that the first column is to be
ignored? Seems you need a way to choose years for 5 columns... and
ignore years (make Visible=No) when they are not specified...
there are much more elegant ways, but this is easy to understand...<g>
on the form where you make your choices for the report (I will refer to
this form as ReportMenu)
make 5 comboboxes to get their values from the available fiscal years
If the same year is entered in 2 comboboxes, the user will see that on
the report and they, presumeably meant that or they will change the
criteria and generate the report again...
these comboboxes on the ReportMenu form, for purposes of this example,
will be named Y1, Y2, Y3, Y4, and Y5.
The 5 subreport controls comprising the columns of the main report will
be set up such that each is linked to one of 5 calculated controls
corresponding to the ReportMenu form choices
ie:
'~~~~~~~~~~~~~~~
ReportMenu unbound combobox control names:
Y1
Y2
Y3
Y4
Y5
'~~~~~~~~~~~~~~~
ReportMenu subreports:
ControlSource --> subReport_formname
Name --> subReport1
LinkMasterfields --> Y1
LinkChildFields --> FiscalYear_controlname
ControlSource --> subReport_formname
Name --> subReport2
LinkMasterfields --> Y2
LinkChildFields --> FiscalYear_controlname
etc
'~~~~~~~~~~~~~~~