Update subforms

C

celineusa

Hello!

I have a form with two subforms (on 2 different tabs).
Form: student information
Subform1: major information for the student
Subform2: required classes for the major for the student

When I choose a major from the Subform1 from the major combobox, it
adds the major to the student.
Then, when I go to the second tab with Subform2, the classes required
are not updated.
To see the classes required, I need to go to another student on the
main form, and go back to the student I was modifying.

I tried If Me.Dirty = True Then Me.Dirty = False
I tried RefreshDatabaseWindow.... but nothing works...

Anybody? Any suggestions?

Thank you
Celine
 
T

tina

try adding the following code to Subform1's AfterUpdate event, as

Me.Parent!Subform2ControlName.Form.Requery

make sure that you use the name of the "container" subform control for
Subform2. sometimes it's the same as the name of the subform, but sometimes
it's different. to get the right name: open the main form in design view.
click *once* on Subform2 (within the main form) to select it. open the
Properties box and click on the Other tab. look at the Name property.

an alternative solution is to click once on Subform1 within the main form,
to select it, and add the following code to the Exit event procedure (if you
see more than two events on the Properties box's Event tab, then you haven't
selected the "container" subform control - try again.)

Me!Subform2ControlName.Form.Requery

hth
 
J

John Vinson

Hello!

I have a form with two subforms (on 2 different tabs).
Form: student information
Subform1: major information for the student
Subform2: required classes for the major for the student

When I choose a major from the Subform1 from the major combobox, it
adds the major to the student.
Then, when I go to the second tab with Subform2, the classes required
are not updated.
To see the classes required, I need to go to another student on the
main form, and go back to the student I was modifying.

I tried If Me.Dirty = True Then Me.Dirty = False
I tried RefreshDatabaseWindow.... but nothing works...

Anybody? Any suggestions?

Requery the subform in the AfterUpdate event of the first:

Parent!Subform2.Requery

John W. Vinson[MVP]
 
C

celineusa

Thanks guys! That almost worked!
Well, in fact, Subform1 (majors) is a datasheet with comboboxes.
When I add a major for a student and I go to Subform2 (required
classes), it works and I can see all the required classes.
However, if I delete a major for a student then go to Subform2, then I
don't see it updated. I still have to change student, and go back to
see the updated result

Any suggestions?

Thanks,
Celine
 
T

tina

if the AfterUpdate event doesn't work in all situations, then try using the
subform control's OnExit event, as i suggested before.

hth
 
C

celineusa

Thanks Tina,

Here is my code:

Private Sub Form_AfterUpdate()
Me.Parent![Classes And Majors subform].Form.Requery
End Sub

Private Sub Form_Exit()
Me.Parent![Classes And Majors subform].Form.Requery
End Sub

So apparently, the afterupdate works only when I add or change a major,
but not when I delete it.
I added the On exit code, but that doesn't seem to do anything. By the
way, there is an AfterUpdate event in the form properties, but no On
Exit event. (i tried the on close, on change, on unload, on
deactivate)... nothing seems to work...

Any suggestions?

Thank you so much,
Celine
 
T

tina

you didn't add the code i previously suggested, or in the place i suggested,
hon.

***********
an alternative solution is to click once on Subform1 within the main form,
to select it, and add the following code to the Exit event procedure (if you
see more than two events on the Properties box's Event tab, then you haven't
selected the "container" subform control - try again.)

Me!Subform2ControlName.Form.Requery

***********

to correctly select the "container" subform control: open the *main* form
in design view. click *once* on Subform1 to select it. open the Properties
box, and look at its' Title Bar: it should say "Subform/Subreport: <name of
subform control>". if the Properties box Title Bar says "Form", then you
probably double-clicked on the subform control, instead of clicking once.
try again.
once you've got the subform control selected: in the Properties box, click
on the Event tab and you'll see only two events - OnEnter and OnExit. place
the above code in the OnExit event procedure.

hth


Thanks Tina,

Here is my code:

Private Sub Form_AfterUpdate()
Me.Parent![Classes And Majors subform].Form.Requery
End Sub

Private Sub Form_Exit()
Me.Parent![Classes And Majors subform].Form.Requery
End Sub

So apparently, the afterupdate works only when I add or change a major,
but not when I delete it.
I added the On exit code, but that doesn't seem to do anything. By the
way, there is an AfterUpdate event in the form properties, but no On
Exit event. (i tried the on close, on change, on unload, on
deactivate)... nothing seems to work...

Any suggestions?

Thank you so much,
Celine
if the AfterUpdate event doesn't work in all situations, then try using the
subform control's OnExit event, as i suggested before.

hth
 
C

celineusa

Great!!

Thank you so much for being so patient!
It works perfectly!!

Take care,
Celine
you didn't add the code i previously suggested, or in the place i suggested,
hon.

***********
an alternative solution is to click once on Subform1 within the main form,
to select it, and add the following code to the Exit event procedure (if you
see more than two events on the Properties box's Event tab, then you haven't
selected the "container" subform control - try again.)

Me!Subform2ControlName.Form.Requery

***********

to correctly select the "container" subform control: open the *main* form
in design view. click *once* on Subform1 to select it. open the Properties
box, and look at its' Title Bar: it should say "Subform/Subreport: <name of
subform control>". if the Properties box Title Bar says "Form", then you
probably double-clicked on the subform control, instead of clicking once.
try again.
once you've got the subform control selected: in the Properties box, click
on the Event tab and you'll see only two events - OnEnter and OnExit. place
the above code in the OnExit event procedure.

hth


Thanks Tina,

Here is my code:

Private Sub Form_AfterUpdate()
Me.Parent![Classes And Majors subform].Form.Requery
End Sub

Private Sub Form_Exit()
Me.Parent![Classes And Majors subform].Form.Requery
End Sub

So apparently, the afterupdate works only when I add or change a major,
but not when I delete it.
I added the On exit code, but that doesn't seem to do anything. By the
way, there is an AfterUpdate event in the form properties, but no On
Exit event. (i tried the on close, on change, on unload, on
deactivate)... nothing seems to work...

Any suggestions?

Thank you so much,
Celine
if the AfterUpdate event doesn't work in all situations, then try using the
subform control's OnExit event, as i suggested before.

hth


Thanks guys! That almost worked!
Well, in fact, Subform1 (majors) is a datasheet with comboboxes.
When I add a major for a student and I go to Subform2 (required
classes), it works and I can see all the required classes.
However, if I delete a major for a student then go to Subform2, then I
don't see it updated. I still have to change student, and go back to
see the updated result

Any suggestions?

Thanks,
Celine


John Vinson wrote:
On 16 Nov 2005 12:41:05 -0800, (e-mail address removed) wrote:

Hello!

I have a form with two subforms (on 2 different tabs).
Form: student information
Subform1: major information for the student
Subform2: required classes for the major for the student

When I choose a major from the Subform1 from the major combobox, it
adds the major to the student.
Then, when I go to the second tab with Subform2, the classes required
are not updated.
To see the classes required, I need to go to another student on the
main form, and go back to the student I was modifying.

I tried If Me.Dirty = True Then Me.Dirty = False
I tried RefreshDatabaseWindow.... but nothing works...

Anybody? Any suggestions?

Requery the subform in the AfterUpdate event of the first:

Parent!Subform2.Requery

John W. Vinson[MVP]
 
T

tina

you're very welcome, glad it worked for you :)


Great!!

Thank you so much for being so patient!
It works perfectly!!

Take care,
Celine
you didn't add the code i previously suggested, or in the place i suggested,
hon.

***********
an alternative solution is to click once on Subform1 within the main form,
to select it, and add the following code to the Exit event procedure (if you
see more than two events on the Properties box's Event tab, then you haven't
selected the "container" subform control - try again.)

Me!Subform2ControlName.Form.Requery

***********

to correctly select the "container" subform control: open the *main* form
in design view. click *once* on Subform1 to select it. open the Properties
box, and look at its' Title Bar: it should say "Subform/Subreport: <name of
subform control>". if the Properties box Title Bar says "Form", then you
probably double-clicked on the subform control, instead of clicking once.
try again.
once you've got the subform control selected: in the Properties box, click
on the Event tab and you'll see only two events - OnEnter and OnExit. place
the above code in the OnExit event procedure.

hth


Thanks Tina,

Here is my code:

Private Sub Form_AfterUpdate()
Me.Parent![Classes And Majors subform].Form.Requery
End Sub

Private Sub Form_Exit()
Me.Parent![Classes And Majors subform].Form.Requery
End Sub

So apparently, the afterupdate works only when I add or change a major,
but not when I delete it.
I added the On exit code, but that doesn't seem to do anything. By the
way, there is an AfterUpdate event in the form properties, but no On
Exit event. (i tried the on close, on change, on unload, on
deactivate)... nothing seems to work...

Any suggestions?

Thank you so much,
Celine

tina wrote:
if the AfterUpdate event doesn't work in all situations, then try
using
the
subform control's OnExit event, as i suggested before.

hth


Thanks guys! That almost worked!
Well, in fact, Subform1 (majors) is a datasheet with comboboxes.
When I add a major for a student and I go to Subform2 (required
classes), it works and I can see all the required classes.
However, if I delete a major for a student then go to Subform2, then I
don't see it updated. I still have to change student, and go back to
see the updated result

Any suggestions?

Thanks,
Celine


John Vinson wrote:
On 16 Nov 2005 12:41:05 -0800, (e-mail address removed) wrote:

Hello!

I have a form with two subforms (on 2 different tabs).
Form: student information
Subform1: major information for the student
Subform2: required classes for the major for the student

When I choose a major from the Subform1 from the major combobox, it
adds the major to the student.
Then, when I go to the second tab with Subform2, the classes required
are not updated.
To see the classes required, I need to go to another student on the
main form, and go back to the student I was modifying.

I tried If Me.Dirty = True Then Me.Dirty = False
I tried RefreshDatabaseWindow.... but nothing works...

Anybody? Any suggestions?

Requery the subform in the AfterUpdate event of the first:

Parent!Subform2.Requery

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