Results 1 to 6 of 6
  1. #1
    cbrsix is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    214

    Toggle button select/deselect all


    I currently have a button on a form (cmdOpenReport) that opens another form that shows a list of all the students currently in that class. There is a drop down box that the user must select a report to view and a date field that must also be entered. This form displays the students name and a checkbox in the column next to the name. I have a toggle button at the top of the checkbox column that toggles between Select All and Deselect All. I want the user to be able to display the selected report for All or just 1 or a couple of the students selected.

    Currently I can view the report for all of the students in that particular class but can't get the checkbox selection to filter the report results further. This is the code that I am using to toggle the selections

    Code:
    Dim strWhere As String
    If Me.SelectReportDropDown = "Health Insurance" And Me.PrintCertificate = True Then
        If Me.Dirty Then 'Save any edits
            Me.Dirty = False
        End If
        If Me.NewRecord Then 'Check these is a record to print
            MsgBox "Select a record to print..."
         Else
            strWhere = " ID_LicensingClassSchedule = " & Me.ClassID
            DoCmd.OpenReport "CertificateHealth", acViewPreview, , strWhere, , "False"
        End If
        DoCmd.OpenReport "CertificateHealth", acViewReport
        Reports![CertificateHealth]!txtDateCompleted = Forms![LicensingClassStudentsSubformPrintCertificates]!txtDateCompleted
    End If
    What am I doing wrong?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    This checkbox is bound to a field?

    I don't see checkbox used in the criteria.

    Does the code to set value of textbox on report work? I would have thought not. Expression in textbox ControlSource can reference the form control.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    cbrsix is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    214
    sorry, that code was only to call the report. here is the code to toggle the checkboxes on the form. Yes, the checkbox is bound.

    Code:
        Select Case tglYesNo
            Case True
              DoCmd.SetWarnings False
                DoCmd.RunSQL "UPDATE LicensingClassStudents SET LicensingClassStudents.PrintCertificate = On WHERE (LicensingClassSchedule.ID = LicensingClassStudents.ClassID)"
                DoCmd.SetWarnings True
                Me.Requery
                Me.tglYesNo.Caption = "Deselect All"
        
            Case False
                DoCmd.SetWarnings False
                DoCmd.RunSQL "UPDATE LicensingClassStudents SET LicensingClassStudents.PrintCertificate = Off"
                DoCmd.SetWarnings True
                Me.Requery
                Me.tglYesNo.Caption = "Select All"
        End Select

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    The button should only run a query to check all. (or uncheck)

    The report qry should pull all students checked. No code needed.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    I have never seen On and Off used as Boolean constants. Does that work? Try True and False instead.

    Don't need the SetWarnings method if use DoCmd.Execute instead of DoCmd.RunSQL.

    I don't see the Yes/No field used in the first procedure as filter criteria. Is it a parameter built into query?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    cbrsix is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    214
    Thanks for the responses. I went in a different direction and removed the toggle field.

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

Similar Threads

  1. Use Toggle button to select subform value
    By DerekAwesome in forum Forms
    Replies: 7
    Last Post: 12-02-2012, 07:15 PM
  2. Toggle Button Help
    By dbalilti in forum Access
    Replies: 1
    Last Post: 07-05-2012, 04:23 AM
  3. Toggle Button Criteria
    By tylerg11 in forum Forms
    Replies: 2
    Last Post: 03-02-2012, 09:28 AM
  4. Toggle Button on Bound Form
    By P5C768 in forum Forms
    Replies: 7
    Last Post: 12-30-2010, 03:00 PM
  5. Toggle Button Options
    By Matthieu in forum Forms
    Replies: 2
    Last Post: 11-23-2009, 04:05 PM

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