How to loop through the subform fields

G

Guest

I have a Form "JobFormA" and a Subform in it "JobFormB"

At certain situation arises (not always) that I have to move to each field
"Status" of the subform and set its value to "Posted". there are sometime 50
records in the subform and some time only few.

Therefore, I am planning to make a Command button and on Click event :
The cursor should move to first field of subform and set the field value to
"Posted" and continues to loop till end.

Please advise, what code should I write to do the above.
 
A

Allen Browne

The simplest way to do this is to use an Update query directly on the
subform's table. This works regardless of any filter applied to the subform

This kind of thing:

Dim strSql As String
strSql = "UPDATE Table2 SET Status = 'Posted' WHERE Table2.FKID = " &
Me.[ID] & ";"
dbEngine(0)(0).Execute strSql, dbFailOnError
Me.[NameOfYourSubformControlHere].Form.Requery
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top