REquery Subform

  • Thread starter RedHeadedMonster via AccessMonster.com
  • Start date
R

RedHeadedMonster via AccessMonster.com

I have a subform (frmCamResourcesSUB1 based on a query result) on a main form
(frmCamResource). If I want to edit data displayed on the subform. You can
click on a name in the subform, a popup comes up that allows you to edit the
data. When I close the popup I want to requery the subform so that the new
edited data is displayed.

I currently have this in the close event of the popup:

Forms![frmCamResource].[frmCamResourcesSUB1].Form.Requery

which only works if I open the popup a 2nd time and close, or if I close the
form and open it again.

I've also tried the following with the same results:

Forms![frmCamResource].[frmCamResourcesSUB1].Form.Refresh
Forms!frmCamResource.frmCamResourcesSUB1.Requery
Forms!frmCamResource.frmCamResourcesSUB1.Form.Requery
Forms!frmCamResource.Requery

I even tried putting the code line twice, since it seemed to want me to run
it twice, but still the same result. Its making me CRAZY! Whats worse is I
have the same code working perfectly for another subform.

What am I missing?
Thanx!

RHM
 
J

Jack Leach

Are you opening the popup in acDialog mode so that the code suspends until
the form is closed? Otherwise the requery might be running before the record
is updated in the popup. Or, are you referring to the name of the control in
the mainform rather than the name of the form itself that is the subform?
Forms![frmCamResource].[frmCamResourcesSUB1].Form.Requery

Technically frmCamResourcesSUB1 is a member of the controls collection of
frmCamResource... therefore you want to preceed it with the bang ! operator
rather than a dot. That might do it...

Forms!frmCamResource!frmCamResourcesSUB1.Form.Requery

I've used both the Form.Requery and SubControlName.Requery before and had
them work... Form.Requery is probably a bit more efficient but I don't think
it's going to make too much of a difference.


Sometimes, for whatever reason, it helps to be a bit more explicit and refer
to the collections themselves rather than using the ES. I've occasionally
ran into a case where I've had to do this for correct results...

Forms("frmCamResource").Controls("frmCamResourcesSUB1").Form.Requery

note that frmCamResourcesSUB1 has to be the name of the control... not the
form.


hth
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)



RedHeadedMonster via AccessMonster.com said:
I have a subform (frmCamResourcesSUB1 based on a query result) on a main form
(frmCamResource). If I want to edit data displayed on the subform. You can
click on a name in the subform, a popup comes up that allows you to edit the
data. When I close the popup I want to requery the subform so that the new
edited data is displayed.

I currently have this in the close event of the popup:

Forms![frmCamResource].[frmCamResourcesSUB1].Form.Requery

which only works if I open the popup a 2nd time and close, or if I close the
form and open it again.

I've also tried the following with the same results:

Forms![frmCamResource].[frmCamResourcesSUB1].Form.Refresh
Forms!frmCamResource.frmCamResourcesSUB1.Requery
Forms!frmCamResource.frmCamResourcesSUB1.Form.Requery
Forms!frmCamResource.Requery

I even tried putting the code line twice, since it seemed to want me to run
it twice, but still the same result. Its making me CRAZY! Whats worse is I
have the same code working perfectly for another subform.

What am I missing?
Thanx!

RHM

--



.
 

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