nested subform problems

G

Guest

I have a subform within a subform within a subform within the main form. On
the main form there are other subforms as well. My problem is that when
information is entered into one of the subforms off of the main form, I need
to cause a requery in a combo box in the nested form, so that when the user
gets to that form, the information will be available to select. I have tried
the following code with only partial success...

This code is in the event of the combo box itself -
Private Sub LogPesticideID_GotFocus()
Me.LogPesticideID.Requery
End Sub

It only works if the user clicks on the field, tabs to the next field and
then tabs back.


I tried this code in the subforms parent form
Private Sub Form_Current()
Me.frmApplicationLogRouteTankPesticidesSubform.Form.LogPesticideID.Requery
End Sub

That only works if the user changes records on that form and then returns to
the record that they want to enter data for.

I also tried lost focus of the immediate parent form - but since it doesn't
lose focus that doesn't work. And some other locations that I don't even
remember now.

Which form should I put the code in and under which event? I would try
putting it in update of lost focus of the form that caries the data that the
other one needs to see, but I don't know if I can or how to identify the
innermost form to requery from an outer form IE. data is entered into
mainform -> subform1 and in mainform -> subform2 -> sub-subform1 ->
sub-sub-subform1 - > combo box needs to be requeried based on the data
entered in mainform -> subform1
 
T

tina

when
information is entered into one of the subforms off of the main form, I need
to cause a requery in a combo box in the nested form, so that when the user
gets to that form, the information will be available to select.

it's not clear to me which subform holds the combobox control, but for my
suggested solution it doesn't really matter. for the sake of explaining,
let's say that you have MainFormA, SubformB, Sub-SubformC, and
Sub-Sub-SubformD, and the combobox control is on Sub-Sub-SubformD. i'll call
the combobox control cboSomething, and i'll name each subform *control* by
the letter of the subform object it contains: ChildB, ChildC and ChildD.

from the database window, open Sub_SubformC in Design view. click once on
the subform control ChildD, to select it. click on the Event tab. make sure
you're on the subform control - there should only be two events listed on
the Event tab: OnEnter and OnExit. add the following code to the Enter
event procedure, as

Me!ChildD.Form!cboSomething.Requery

since your stated requirement is that the combobox control is "ready" when
the user gets to it, the above code placement means that when the user
enters the subform that the combobox is on, the combobox control will be
requeried.

hth
 
G

Guest

that did it... thanks for you help

tina said:
it's not clear to me which subform holds the combobox control, but for my
suggested solution it doesn't really matter. for the sake of explaining,
let's say that you have MainFormA, SubformB, Sub-SubformC, and
Sub-Sub-SubformD, and the combobox control is on Sub-Sub-SubformD. i'll call
the combobox control cboSomething, and i'll name each subform *control* by
the letter of the subform object it contains: ChildB, ChildC and ChildD.

from the database window, open Sub_SubformC in Design view. click once on
the subform control ChildD, to select it. click on the Event tab. make sure
you're on the subform control - there should only be two events listed on
the Event tab: OnEnter and OnExit. add the following code to the Enter
event procedure, as

Me!ChildD.Form!cboSomething.Requery

since your stated requirement is that the combobox control is "ready" when
the user gets to it, the above code placement means that when the user
enters the subform that the combobox is on, the combobox control will be
requeried.

hth
 

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