• Select Label by Name in Report

    Author
    Topic
    #466130

    Sometime in the past, this database was written with 10 similar reports; each highlighting one label by shading. The only other difference is the Titles. Changing the titles in the Open event of the report is easy. Choosing a label to highlight is proving harder.

    I have built a Master Report and plan to change the Title and the highlighted label “on the fly.”

    Code:
        theCurrentTitle = "Buy/Sell Code-Options Validation Report"
        Title2Text = "Report for Trade Codes: 3, 4 , 5, 6, D, E, F, G"
        HighlightLabel = Reports("rptmaster").xxxx                      'Problem here
      '  DoCmd.OpenReport "rptBuySellCode_Options", acViewPreview, "", "", acNormal
        DoCmd.OpenReport "rptMaster", acViewPreview, "", "", acNormal

    Suggestions?

    Viewing 3 reply threads
    Author
    Replies
    • #1206693

      What does the “xxxx” stand in place of?
      I don’t remember this, as I usually re-learn it only when I have to, but can you paint the highlight via report code in the “on format” or “on print” events?
      Pat

    • #1206705

      What version of Access are you using? Later versions allow you to pass a parameter to a report using OpenArgs

      Code:
      theCurrentTitle = "Buy/Sell Code-Options Validation Report"
       Title2Text = "Report for Trade Codes: 3, 4 , 5, 6, D, E, F, G"
       strHighlightLabel = "xxx" 'Problem here
       DoCmd.OpenReport "rptMaster", acViewPreview, "", "", acNormal,strHighlightlabel

      Then the report could loop through its labels, comparing their name with Openargs, and hightlight the one that matches.

    • #1206786

      Using Access 2007. The XXX was representing an instruction I could not find.

      Been a while since I used OpenArgs.

      ==========
      On one kind of report, I need to set one label to background shade; on a different iteration, I will be setting a different label. Can I do this withut having 8 versions of essentially the same report??

    • #1206833

      OpenArgs is one way to pass a parameter to a report. Things get more complicated if you need to pass multiple bits of data.

      One option is to put the various bits of data into the one string, that is passed using OpenArgs. The report would then have to parse this to extract the various bits.

      My preference is to launch the report from a form, and have the various options selected on the form. Leave the form open when the report is launched, and the report can check the options directly on the form.

      e.g.
      Select Case Forms(“frmMenu”)!optSelect

      in the On Open event of the Report

      I was not sure what your XXX was. I just used it as the name of the Label you wanted highlighted.

    Viewing 3 reply threads
    Reply To: Select Label by Name in Report

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: