On Deactivate event does not fire when switching forms

C

cory00

I have a parent form and a child form. The child form is filtered to
show only records related to the current record shown on the parent
form.

If I have both forms open, and enter a new record in the parent form,
then click on the child form, the child form does not update with the
foreign key from the parent form, since the data in the parent form is
not saved yet.

I am trying to use the on deactivate event in the parent form to save
the data, and filter the child form. However, when I enter the data in
the parent form, then click on the child form, the on deactivate event
does not fire(the activate event of the child form does not fire
either). If I click back to the parent form, then click the child form
again, then the on deactivate event will fire. I am using access 2003.

Does anyone know how to work around this?

thanks
 
R

Rick Brandt

I have a parent form and a child form. The child form is filtered to
show only records related to the current record shown on the parent
form.

If I have both forms open, and enter a new record in the parent form,
then click on the child form, the child form does not update with the
foreign key from the parent form, since the data in the parent form is
not saved yet.

I am trying to use the on deactivate event in the parent form to save
the data, and filter the child form. However, when I enter the data in
the parent form, then click on the child form, the on deactivate event
does not fire(the activate event of the child form does not fire
either). If I click back to the parent form, then click the child form
again, then the on deactivate event will fire. I am using access 2003.

Does anyone know how to work around this?

thanks

Use of an embedded subform would do all of this work for you automatically. Is
there a good reason why you don't use that method instead of two separate forms?

If you are just concerned about form real estate use a TabControl.
 
G

Guest

Try the afterinsert event in the parent form. By that point the new record
will be saved. Use oncurrent for existing records, but set a switch in
beforeinsert and reset it in afterincert then check it in oncurrent so you
don't get confused. Also, remember that beforeupdate and afterupdate will
also fire when further changes are made to a newly inserted row.

There are a lot of reasons not to use subforms. I have an app that can have
many forms open at once that need to change in response to changes on one of
the forms. Subforms are great for simple one to many relationships, not so
good for linked lists, trees, etc.
 

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