Loop through Sub Form Table Controls (1 Viewer)

Mister-B

New member
Local time
Today, 12:50
Joined
Apr 10, 2020
Messages
10
Hi there,

I have a main form (Daten) with a sub form (BewerberUF) in my database. The sub form is shown as a table. In the sub form one of the columns ("Ausgewählt") is made up of checkboxes. Is there a way (possibly with a command button) to loop through one of the columns and set all the checkboxes in that column to "true".

Thanks and kind regards,
Martin
 

Attachments

  • SubForm.png
    SubForm.png
    59 KB · Views: 30

theDBguy

I’m here to help
Staff member
Local time
Today, 03:50
Joined
Oct 29, 2018
Messages
21,473
Yes. You should be able to use a standard Do While loop on the subform's recordset object.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 06:50
Joined
May 21, 2018
Messages
8,529
I would not loop but use an update query

Something like this assuming the subform is filtered by the mainform value
Code:
dim strSql as string
strSql = "Update tblBewerberUF Set Ausgewählt = true where SomeForeignKey = " me.SomePrimaryKeyValueInMainForm
currentDb.execute StrSql
subform.form.refresh

If you loop the recordset you will move the recordselector and may get some flashing.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 05:50
Joined
Feb 28, 2001
Messages
27,186
MajP's solution is also going to be a lot faster if you have a lot of entries in the sub-form.
 

Mister-B

New member
Local time
Today, 12:50
Joined
Apr 10, 2020
Messages
10
I would not loop but use an update query

Something like this assuming the subform is filtered by the mainform value
Code:
dim strSql as string
strSql = "Update tblBewerberUF Set Ausgewählt = true where SomeForeignKey = " me.SomePrimaryKeyValueInMainForm
currentDb.execute StrSql
subform.form.refresh

If you loop the recordset you will move the recordselector and may get some flashing.
Thank you so much. This is exactly what I was looking for,
 

Users who are viewing this thread

Top Bottom