Share via

Select all checkbox

Anonymous
2012-03-16T01:25:51+00:00

How can I create a "select all" checkbox for my form? I would also like to do something similar with a combo box where if I select text in an unbound combo box it populate every combo box on the form.  Is this possible?. Please note, that the checkboxes and combo boxes on the form were not individually created and the total number of them can change if my student count changes up or down. The code I found for the select all looks like this, however when I select the "select all" checkbox it only select the first checkbox on the form.  Also note, I can not name each checkbox or combo box on my form like cmbx1, cmbx2. etc.  The name is based on a table which is TempAttendance.

Private Sub cbxSelectAll_Click()

If Me.cbxSelectAll Then

Me.TempAttendance = True

End If

End Sub

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2012-03-17T18:12:35+00:00

Here are some (possibly a bit old) references that I've recommended over the years:

Utter Access discussion forum and resources:

http://www.utteraccess.com

Jeff Conrad's resources page:

http://www.accessmvp.com/JConrad/accessjunkie/resources.html

The Access Web resources page:

http://www.mvps.org/access/resources/index.html

Roger Carlson's tutorials, samples and tips:

http://www.rogersaccesslibrary.com/

A free tutorial written by Crystal:

http://allenbrowne.com/casu-22.html

A video how-to series by Crystal:

http://www.YouTube.com/user/LearnAccessByCrystal

MVP Allen Browne's tutorials:

http://allenbrowne.com/links.html#Tutorials

Crystal's and Allen's tutorials would be a good place to start.

Was this answer helpful?

0 comments No comments

7 additional answers

Sort by: Most helpful
  1. Anonymous
    2012-03-16T12:31:37+00:00

    As John and Tom have pointed out you should not do this.  Instead, insert multiple rows into a table and use a subform.  In the demo StudentLog file to which I referred you in another thread for instance,  you could add a button to the Attendances subform in the Courses form to record all students registered for a course as attending the currently selected session by putting the following code in the button's Click event procedure:

        Dim strSQL As String

        strSQL = "Insert Into CourseAttendances" & _

            "(StudentID,CourseID,CourseDate) " & _

            "SELECT StudentID, " & Parent.[CourseID] & ", #" & _

            Format(Parent.[sfcCourseSessions].[Form].[CourseDate], "yyyy-mm-dd hh:nn:ss") & _

            "# FROM CourseRegistrations WHERE CourseID = " & Parent.[CourseID]

        CurrentDb.Execute strSQL

        Me.Requery

    Note here that the usual dbFailOnError option of the Execute method is omitted here so that if some registered students are already recorded as attending the session the others will still be added, ignoring the key violation error resulting from the existing rows.

    I've amended the file in my SkyDrive folder to incorporate this amendment.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2012-03-16T12:18:24+00:00

    Maybe I'm getting in over my head.  This my first time using Access.  The record source for the form is StudentInfo.  My form contains the following: StudentID (auto number), First Name (text), Last Name(text), Absent (yes/no - check box), and Reason Absent (text - combo box w/ value list).  The forms footer holds an unbound textbox for selecting the date and a button to submit it all to my AttendanceTable.  The AttendanceTable contains the following: AttendanceID (auto number), StudentID (number), First Name (text), Last Name (text),  InClass (yes/no), AttendanceDate (date/time), and ReasonAbsent (text). Everything is working fine, I just wanted to know if it was possible to add a "select all" check box on the forms footer, in case I needed to select all students on the form.  I've made an attempt to add on, but when I select it, it only selects the first check box on my form. 

    When I say the number of students changes, I mean if we have another student move in and I add them to the StudentInfo table, it increases my student count by one and when I open my StudentAttendance Form that student is obviously added to the form, increasing the total on the form. 

    I hope I've explained this better

    Was this answer helpful?

    0 comments No comments
  3. Tom van Stiphout 40,211 Reputation points MVP Volunteer Moderator
    2012-03-16T02:25:38+00:00

    If you really wanted to, there is a way to iterate over the Fields collection of the Tabledef object and do what you want, but DON'T GO THERE; rather listen to John Vinson and make sure you have a Relational Database design that works. Then the other stuff will fall into place.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2012-03-16T01:39:56+00:00

    WHOA. You appear to be on the wrong track! Redesigning your Form or your table when data - the number of students - changes indicates that your tables are not correctly normalized.

    What is the Form's Recordsource property? What's the structure of your table? What are these checkboxes? What's the stucture of TempAttendance?

    Was this answer helpful?

    0 comments No comments