Results 1 to 5 of 5
  1. #1
    tylerg11 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Posts
    200

    Open Report and Hide Control using VBA

    I am using the following syntax to open my report:



    Code:
    DoCmd.OpenReport "[Report]", acViewPreview
    But I also want to be able to hide a control on that report using VBA. I am using the following syntax and it isn't working for me. Any ideas?

    Code:
    Reports![ReportName]![SubReportName]![ControlName].Visible = False

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You might try:
    Reports![ReportName]![SubReportName].REPORT.[ControlName].Visible = False

  3. #3
    tylerg11 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Posts
    200
    Still doesn't work. An error pops up that says, "Run-time error '2455': You entered an expression that has an invalid reference to the property Form/Report."

    I wonder if you can't hide a control with code??

  4. #4
    tylerg11 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Posts
    200
    Oh, I figured it out. Dumb mistake. I am opening the report in PrintPreview so I obviously can't hide a control at that point. It works in Report View. I wonder if I can open it in Report View, hide the control, and then display in Print Preview

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I'll bet you will figure it out.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Hide Report after Opening?
    By Heatshiver in forum Reports
    Replies: 4
    Last Post: 04-06-2012, 12:26 PM
  2. How do i open a form and hide a field?
    By xwnoob in forum Forms
    Replies: 1
    Last Post: 01-05-2012, 03:27 AM
  3. Hide each control, control group or subform?
    By BRV in forum Programming
    Replies: 2
    Last Post: 12-09-2011, 09:36 AM
  4. Option Control to hide/show page tabs
    By tandridge in forum Forms
    Replies: 3
    Last Post: 12-08-2011, 10:15 AM
  5. Hide Report on Textbox Value
    By alyon in forum Access
    Replies: 4
    Last Post: 07-29-2011, 11:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums