Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2004
    Posts
    7

    Unanswered: A97: Programmatically find subreport name in a report

    All:

    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.

    Any help?

    Thanks,

    Ron

  2. #2
    Join Date
    Dec 2003
    Posts
    268

    Use your controls

    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
    end if
    next ctl

    When declaring the variable in the module don't forget to declar it as public.

    This should work.

  3. #3
    Join Date
    Dec 2003
    Posts
    268

    Another Option

    I was thinking about this more.....

    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.

  4. #4
    Join Date
    Jan 2004
    Posts
    7
    Mjweyland:

    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.

    Hope I made myself a little clearer.

    Thanks again,

    Ron Mc

  5. #5
    Join Date
    Dec 2003
    Posts
    268

    Should Still work

    I am a little confused by this. Are both sub reports in teh detail section of the report. Can you post an example? I don't really undertand what you are trying to do.

    However, you can cycle through controls on a report and reassign to a text string when values change, as with reports. You can then cycle through to get names.

  6. #6
    Join Date
    Jan 2004
    Posts
    7
    mjweyland:

    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.

    Ron
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •