Results 1 to 3 of 3
  1. #1
    M.Enders is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jun 2017
    Posts
    9

    VBA Form to Report Conditional

    Good Afternoon all,

    I have a form that has control buttons on it to open reports, and I want to add into the VBA so that based on a check box on the form certain text boxes on the report are shown or not.

    Currently I have:

    Private Sub Command0_Click()




    If Me.Check1 = False Then

    DoCmd.OpenReport "ReportRecallRoster", acViewPreview

    Else
    DoCmd.OpenReport "ReportRecallRoster", acViewPreview

    End If


    End Sub

    I am not sure what to add into the sections to control if a text box is shown, also I am not sure if it goes on the report or the form either any help would be great

    Thanks


    Marty

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    To affect visibility it would go on the report. Presuming you leave the form open, code in the format event of the section containing the controls:

    Code:
    If Forms!FormName.Check1 = False Then
      Me.TextboxName.Visible = False
    Else
      Me.TextboxName.Visible = True
    End If
    Someone would invariably chime in with this, which is shorter but confusing to beginners:

    Me.TextboxName.Visible = Forms!FormName.Check1
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Oh, and if you didn't want to leave the form open, you could pass True/False to the report in OpenArgs and use that.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. conditional color on report
    By dadanford in forum Reports
    Replies: 2
    Last Post: 12-08-2017, 04:54 PM
  2. report conditional formating
    By Arroyo in forum Reports
    Replies: 3
    Last Post: 10-17-2017, 12:22 AM
  3. Conditional Value in report design?
    By ieatglitter in forum Reports
    Replies: 2
    Last Post: 11-30-2014, 02:37 AM
  4. Conditional Formating In A Report
    By cadsvc in forum Reports
    Replies: 11
    Last Post: 11-02-2010, 04:47 PM
  5. Conditional formatting in report
    By RickM in forum Access
    Replies: 1
    Last Post: 09-10-2009, 06:21 PM

Tags for this Thread

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