Refreshing subforms

RevJeff

Registered User.
Local time
Today, 08:25
Joined
Sep 18, 2002
Messages
129
Let me try to explain this....

I have a form with a subform on it which has a subform on it. The second subform has a listbox. The listbox is pulling data from a query. The query is driven by a field on the main form. How do I get the listbox to refresh/requery when the field on the main form updates.

I have the field do a Me.Refresh when it changes, but that doesn't make a difference.

I hope that makes sense.

Thanks
 
subforms are a pain in the A************** actually. :)

You might not believe this, but the requery code you have to use for your listbox actually depends on where the focus is on the entire form object at the time the code is run. Say, for example, the FOCUS of the form object actually exists in the main form at the time you want to update the listbox. If that is the case, you use this code to requery it:
Code:
Me.sub1Container.SetFocus
   Me.sub1Container.Form!sub2Container.SetFocus
      Me.sub1Container.Form!sub2Container.Form!ListboxName.SetFocus
         Me.sub1Container.Form!sub2Container.Form!ListboxName.requery
See this post for additional insight perhaps...

http://www.access-programmers.co.uk/forums/reputation.php?p=685921
 
Ok, I tried this:

Me.frmClient.SetFocus

(frmClient is the subform)

and it gives me an error "Method or data member not found"

I also tried this (which is the format I found on a different thread:

Me!frmClient.Form!frmPets.Form!frmPetList.Form!List0.SetFocus

(frmClient is subform1, frmPets is subform2, frmPetList is subform3)

and I get an error that it can't find the field "frmClient".

The field on the main form is typed in.

Any other ideas?
 
that is very tough to follow Jeff. I would say to just upload the database so we can take a look if you can do that...
 
subforms are a pain in the A************** actually. :)

You might not believe this, but the requery code you have to use for your listbox actually depends on where the focus is on the entire form object at the time the code is run. Say, for example, the FOCUS of the form object actually exists in the main form at the time you want to update the listbox. If that is the case, you use this code to requery it:
Code:
Me.sub1Container.SetFocus
   Me.sub1Container.Form!sub2Container.SetFocus
      Me.sub1Container.Form!sub2Container.Form!ListboxName.SetFocus
         Me.sub1Container.Form!sub2Container.Form!ListboxName.requery
See this post for additional insight perhaps...

http://www.access-programmers.co.uk/forums/reputation.php?p=685921

Can you do all of that in one line using the name of the main form?
 
Can you do all of that in one line using the name of the main form?
maybe...but I like to complicate the heck out of things, so it's not real feasible for me to say 'yes' to that. But, if it IS indeed possible, I would assume that this would suffice:
Code:
me.requery
  me.refresh
:p
 
I found the problem I was having. The first subform name was wrong. DUH!!

Thanks for all your help.
 

Users who are viewing this thread

Back
Top Bottom