Consulting

Results 1 to 3 of 3

Thread: OptionGroup on Report

  1. #1
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,388
    Location

    OptionGroup on Report

    I have an executive level report based on a query (A) that displays a list of project update briefing due dates. This is all well and good provided the staff properly enters the project update due date in the table record. If the due date is not entered then the project (and its required update briefing) is not included in the report.

    To prevent that, I created a second query (B) that includes both projects with a future due date and project where no due date is defined.

    I wanted the report to open showing results of query B and include a method to toggle the displayed results between query A and B.

    I was able to do that with a button on the report:

    Private Sub cmdToggleView_Click()
        If Me.cmdToggleView.Caption = "Click to Filter List" Then
            Me.cmdToggleView.Caption = "Click to Show Full List"
            Me.RecordSource = "qryA"
            Me.Requery
        Else
            Me.cmdToggleView.Caption = "Click to Filter List"
            Me.RecordSource = "qryB"
            Me.Requery
        End If
        lbl_Exit:
        Exit Sub
    End Sub
    It worked flawlessly.

    Now, I thought a better design would be to have a pair of option buttons where the default value would be the Full List (qryB) and the user could click the "A" option to toggle the

    Private Sub frmToggleView_Click()
        If Me.frmToggleView.Value = 1 Then
            Me.RecordSource = "qryA
            Me.Requery
        Else
            Me.RecordSource = "qryB"
            Me.Requery
        End If
        lbl_Exit:
        Exit Sub
    End Sub
    This method works as well, but the option buttons appear dimmed (neither are displayed as selected or not selected) and they don't change state when clicked.

    What am I doing wrong?

    Thank you.
    Last edited by Aussiebear; 07-04-2024 at 01:08 PM.
    Greg

    Visit my website: http://gregmaxey.com

  2. #2
    VBAX Mentor
    Joined
    Nov 2022
    Location
    The Great Land
    Posts
    371
    Location
    Reports are not intended to be interactive, that's what forms are for. Assume you are aware that buttons will only work in ReportView, not PrintPreview.

    Are these option buttons within an OptionGroup control? Works for me.

    Was your original button a Toggle button? That sounds better to me.
    How to attach file: Reading and Posting Messages (vbaexpress.com), click Go Advanced below post edit window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,388
    Location
    No, it was just a regular button. I ended up using a toggle button but even then it seems clunky. I assumed that one could evaluate the state
    with VBA and then proceed accordingly. Not the case.

    Thanks.
    Greg

    Visit my website: http://gregmaxey.com

Posting Permissions

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