By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,564 Members | 1,081 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,564 IT Pros & Developers. It's quick & easy.

Programaticaly populate a sub-form

P: n/a
Hello all,

I'm using A97 on W2K.

I've got a form, say "frmMain" which contains a sub form, say
"frmMainSub". This sub form is a "continue mode" style form (traducted
from french. don't know the exact term in english). So I can add,
remove, modify records "live".

What I must do (asked by the boss!!), it's to use another form, say
"frmChoice", which would give users the possibility to select one or
more record from a fixed number of records, to populate afterward
frmMainSub, by clicking checkboxes. This form is more "graphical" and
visual and fast for the user than entering each line in frmMainSub.
But, I've to run the "frmMainSub.AfterInsert" function after inserting
these record programaticaly because some updates are done.

Right now, I've achieved all that. I added a button on frmMain which
open dialog frmChoice and I retreive selected data. Then (all from
frmMain module):
1- I add the first record to the table source of frmMainSub.
2- I requery frmMainSub.
3- I FindFirst the added record.
4- I run frmMainSub.AfterInsert (wich update a couple of fields
directly in frmMainSub. For some reasons, I don't want to just
cut&paste this code and run it in an update query in frmMain module.)
5- I run DoCmd.RunCommand acCmdSaveRecord
6- I redo all this with the second selected choice, ... third, ....

But, it looks like point #5 do not work. I end up with frmMainSub
populated with lines added but not updated (as if point #4 did
nothing). Except for the last inserted line which as been updated
(visualy in frmMainSub) but not in the table source.

Anybody has solution to this situation. Other suggestion to acheive
this similarly.

Thanks for your time.

Yannick

Dec 6 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Problem solved.

For those who will face the same situation, I added a Requery call at
the end of frmMainSub.AfterInsert.I don't know why it was needed but it
works. I realise that point #5 was in fact at the end of the function
in point #4. And I added the Requery call after the SaveRecord command.

1- I add the first record to the table source of frmMainSub.
2- I requery frmMainSub.
3- I FindFirst the added record.
4- I run frmMainSub.AfterInsert (wich update a couple of fields
directly in frmMainSub. For some reasons, I don't want to just
cut&paste this code and run it in an update query in frmMain module.)
5- I run DoCmd.RunCommand acCmdSaveRecord
6- I redo all this with the second selected choice, ... third, ....

Dec 6 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.