Unanswered: A97: Programmatically find subreport name in a report
I have a report with two subreports.
I wish to print a defined name of the data from subreport #1 in the page header section on each page or column of the report as long as I am printing subreport #1 then switch to a defined name for the data in subreport #2 when I enter and print subreport #2.
You can cycle through the controls on a form and determine thier names. You can then either store this value in a text box and reference the report to that text box if the form is open or you could store the value as a variable in a module that the reoport will reference, so the initial form does not need to be open.
'find the report name
dim ctl as control
for each control in controls
if ctl.controltype = acsubform then
textbox = ctl.name
'or if you are storing as a public variable in a module
strSubformName = ctl.name
When declaring the variable in the module don't forget to declar it as public.
Or if you are only looking at two forms and each form has its respective button then on the click event for that particular button you could store the value in (as described earlier) either a textbox hidden to the uers or in a variable in a module.
This too will work.
p.s. I forgot to tell you to hide the text box on the previous email.
Thanks for your response but it appears that I didn't make myself clear. I'm working with a report and not forms. Let me redefine my problem.
I can write VBA code in the underlying report page header section to write to a text box in the page header. However, it seems to me that if I can get the name of the subreport (object name) in the report, I can write an IF statement that will let me know when I finish printing subreport #1 and begin subreport #2.
I've attached a sample database to demonstrate what I mean.
1. I can get the column header "TEST DATA" to print in the page header while the subreport "srptTEST DATA" prints (see the VBA statement at the end of the event procedure in the page header section) but I want the column header to print "PAST PRESIDENTS" when srptPAST PRESIDENTS begins printing.
2. I'm sorry but I don't know what you mean by "cycle through controls on a report and reassign to a text string when values change." VBA is not my strong suit.