Find a Record in a Subform

T

Trini Gal

Hello,

I have tried everything. Researched everywhere, asked for help, and haven't
been very successful. I'm trying this forum

I need to know how would I code a find button in one form to look for a
record in another form's sub form?

Thanks in advance.
 
R

RuralGuy

That "Other Form's SubForm" is based on a query/table that you could search
directly without using the other form. I'm curious, why would you want to do
such a thing?

Hello,

I have tried everything. Researched everywhere, asked for help, and haven't
been very successful. I'm trying this forum

I need to know how would I code a find button in one form to look for a
record in another form's sub form?

Thanks in advance.

_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
T

Trini Gal

RuralGuy,

I should maybe explain a little.

I have a main form (frmADD_LEAK_FORM) with a subform (frmADD_LEAK_SUBFORM)
within which has existing data. When a user wants to edit data in the
subform, they click on the Edit button in the subform, which opens up my
dialog pop-up form (frmEDIT) where they have to enter their name and the
current date. The user would then click the Ok button to get back to the
original form. I had the DoCmd.OpenForm code attached to the Ok button, but
that opens up another instance of the subform. I need to just go back to the
record thats being edited. The primary key is LEAKID.

Any suggestions? I was thinking maybe the goto Record, but I'm not sure how
to do this.

Thanks for in advance for your help.
 
V

Van T. Dinh

Did you close or hide the form "frmADD_LEAK_FORM" when you opened the form
"frmEdit"?

It may be easier for you to leave it open in the backfround (hidden if
required) when you open frmEdit and simply requery the Subform when OK
button is clicked (after the update has been written into the Table) to
refresh the data displayed on the Subform.
 
T

Trini Gal

Van,

My form "frmADD_LEAK_FORM" is kept opened when the other form "frmEDIT" is
opened. How would I go about requerying the subform?

Thanks
 
R

RuralGuy

If you use the acDialog parameter then code in the source SubForm is suspended
while the frmEdit is open. As soon as you close frmEdit the SubForm code starts
executing again. Therefore, put a Me.Requery right after the DoCmd.OpenForm
line of code in the SubForm.

Van,

My form "frmADD_LEAK_FORM" is kept opened when the other form "frmEDIT" is
opened. How would I go about requerying the subform?

Thanks

_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
V

Van T. Dinh

Use the Unload Event of the frmEdit to requery with code like:

dbEngine.Idle dbRefreshCache
Forms!frmADD_LEAK_FORM!SubformControl.Form.Requery

Note: you need to check the name of the SubformControl in the DesignView of
the Main Form since the SubformControl name may be different from the name
of the Form being used as the Subform (more technically accurate, being used
as the SourceObject of the SubformControl).
 
Top