Loop through Sub Form Table Controls (1 Viewer)

Mister-B

New member
Local time
Today, 18:07
Joined
Apr 10, 2020
Messages
13
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: 56
Yes. You should be able to use a standard Do While loop on the subform's recordset object.
 
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.
 
MajP's solution is also going to be a lot faster if you have a lot of entries in the sub-form.
 
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

Back
Top Bottom