clear records on subform when go to knew record on main form

G

Guest

I am using the unbound combo fields on the main form (date, joblist,
personnel) to populate and schedule fields in a subform when I navigate to a
new record (new day) on the main form. I would like the subform records to
be cleared out for the new record but remain for the day that has already
been scheduled.

What code and where do I put it.

thanks,
barb
 
J

J

It should be automatic (no code) if your main form and subform are set
up properly.

Definitions that will make my explanation easier... just sub in your
own names:
FormMain - Your main form
TableMain - The table or recordset underlying your main form
FormSub - Your sub form
TableSub - The table or recordset underyling your sub form

The checklist:
( ) Does TableSub have a field that stores a reference to TableMain's
primary key?
( ) Did you set up a many-to-one relationship between TableSub and
TableMain?
( ) Did you set the "child" and "master" fields properly on the
subform in FormMain?

If all of those are true, then going to a new record on FormMain
should 'clear out' FormSub. Going to a new record is NOT the same
thing as just typing in a new date. Typing in a new date just changes
the record in TableMain you're currently looking at and has no effect
on FormSub or TableSub.

Hope that helps,
~J
 
P

pietlinden

I am using the unbound combo fields on the main form (date, joblist,
personnel) to populate and schedule fields in a subform when I navigate to a
new record (new day) on the main form. I would like the subform records to
be cleared out for the new record but remain for the day that has already
been scheduled.

What code and where do I put it.

thanks,
barb

why not bind the recordsource in the On Change event of one of the
three combobox fields. Limit to the single record, and you should be
fine...
 
J

John W. Vinson

I'm seeing this problem as well. I've checked off on all three of your points but am still have the same problem. I have stepped through what's going on in the subform when a new record is created in main form and the subform keyfields are set to the same value as whatever prior existing record was last looked at. If I try to force the keyfields on the subform to be the key value from the new record, Access raises an error regarding trying to insert a record and the parent key doesn't exist. I've also noted that the subform(s) are being put into an insert record state when a new record is created on the main form.

Still searching for a solution...

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com

Jim, it is really helpful when you post a reply to leave at least some
indication of what you are replying TO. There are a lot of messages in this
newsgroup and a lot of different newsreaders and websites...

John W. Vinson [MVP]
 

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