Setting a label on a report after opening it

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • calogero
    New Member
    • Aug 2011
    • 5

    Setting a label on a report after opening it

    I am using MS Access 2010. I want to set a label on a report after opening it. I open the report with the following command, where sReport holds the report name:
    Code:
    DoCmd.OpenReport sReport, acViewPreview
    I then check to make sure that the action didn't fail.

    I then set the label with the following code:
    Code:
    Reports(msObject).xlblOption.Caption = Form_fFStMenus.xlblActiveMenu.Caption & nOption
    The code does not give me an error, but neither does the xlblOption label have the desired value.

    Any suggestions about what I am doing wrong?
    Last edited by NeoPa; Feb 9 '12, 02:21 PM. Reason: Added mandatory [CODE] tags for you
  • Mihail
    Contributor
    • Apr 2011
    • 759

    #2
    Manage that in Open event of the report itself.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32662

      #3
      Very little information to work with here (You may want to consider better preparation of your question in future), but have you tried :
      Code:
      Reports(sReport).xlblOption.Caption = Form_fFStMenus.xlblActiveMenu.Caption & nOption

      Comment

      • calogero
        New Member
        • Aug 2011
        • 5

        #4
        Thank you; that did the trick. But I couldn't just set the label directly to the value of the Form label. I got it to work by setting a public variable to the Form label and then setting the Report label to that public variable in the Report`s Open event

        Comment

        • calogero
          New Member
          • Aug 2011
          • 5

          #5
          Sorry, my sample code left out the fact that msObject actually held the same value as sReport. It`s just that sReport is the parameter value in a subroutine I call to do the print preview and msObject is a private variable in a class that holds the commands to be executed.

          Thanks for the suggestion though.

          Comment

          Working...