 |
| Access VBA Discuss using VBA for Access programming. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 17th, 2005, 02:02 AM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Reports in access
Hey Guys,
I was wondering if any of you out there had experience with Access Reports. Specifically, I want to programmatically change headers in a report. Here is what I have going. I have a table that is populated with different data depending on what the user selects. The reports are tied to that table, so if I knew how to programmatically change the report header depending on what the user chose for the click event on the form, then I would only need 1 report instead of several.
Also, in a vba form for access, if you want actions to occur when you open the form, you write this sub routine:
private sub form_load
end sub
If I could find the counterpart for that code in a report, that would be awesome. Like, have a funciton called automatically when you open a report.
Thanks,
Ryan
nikotromus
__________________
nikotromus
|
|

July 18th, 2005, 06:50 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
Hey,
If the data you want to show up in the header is from a form field, then you can just put a text box on the header, remove the label for the text box, and type in the name of the field. Format this to look like the rest of your caption, and when the form loads, this will cause the name from the field to show up in the header. I use this method on reports. It works if there is only one group of data related to the form field. If there is more than one, then your header has the field data for the first group, and not the other groups, so the report is mistitled.
I typically create very few reports and change them programatically as needed.
There are many events associated with the opening of a report. Open the report's property dialog box, and click the events tab. You want On Open, or On Load, depending on your need.
HTH
mmcdonal
|
|

July 26th, 2005, 06:02 PM
|
|
Registered User
|
|
Join Date: Jun 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hey,
Try making the header visible=false
Dakota
|
|

July 27th, 2005, 03:46 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
Suppose, for example, that you have a combobox on a form that someone picks the office location (i.e. a city). In the report's header's ON FORMAT event you'd have (using fake names):
Me.txtReportTitle = "Report for " & Forms.frmMyForm.Form.cboCity & " Office"
And the report title will always reflect the users choice.
In reports, there is no ON LOAD event for the form per se. Each section of the report has an ON FORMAT event that executes when that portion of the report is being initialzed for display/print. Reports DO have an ON OPEN event just like forms.
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
|
|

July 31st, 2005, 12:57 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2005
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Forms have an On load and on open events. Reports only have on open event.
HTH...
Boyd
Access Based Accounting/Business Solutions developer.
|
|
 |