Update underlying table

G

Guest

I am an occasional programmer, and a relative novice.
I have a form, frmA, that contains two subforms, frmB and frmC. I have
written a procedure to copy certain fields from frmB to frmC, based on the
value of a checkbox in the underlying table of frmB. If the checkbox is True,
the relevant fields in the records are copied, else the record is ignored.
Everything works fine when I manually select the checkboxes. I have written
another procedure to select all the checkboxes of form B as True when I press
a button. This was accomplished by opening a recordset clone based on form B,
and moving through the records using a Do .. Loop procedure. The procedure
seems to work; the checkboxes are all checked, but when I run the code to
copy the records, only the first record copies. I have tried to requery the
form, but it makes no difference. The only thing that fixes it is to close
and open the form again. There must be a more elegant way to do this. I would
appreciate any suggestions.
Many thanks.
 
A

Alex Dybenko

difficult to say without looking at your code. i think you can try to
perform both task in one loop - you set checkboxes and same time copy
records.
 
K

Kevin K. Sullivan

Instead of requerying frmA after the code, it sounds like you need to
requery the frmC subform. Try (in frmA's code):

Me!frmCsubformName.Form.Requery

As far as elegance, the fact that you need to keep records in tblB and
tblC in sync suggests that those fields need to be in the parent table,
tblA. (Consider this a gentle nudge toward normalization).

HTH,

Kevin
 
G

Guest

Thank you for your reply. No, your suggestion didn't help. It still only
copies the first record unless I close and open the form. I have tried to
Requery every form.

Alex suggested I did everything in one loop, and that is one way of fixing
the problem that I did not think about.

Re. normalization. I appreciate your comment. I will go back to the design
board and think about the structure of my tables again.
 

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