Find a Record in a Subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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.
 
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.
 
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.
 
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
 
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.
 
Reference other forms Sub Forms

Reference form

!Form.{formName}.requery

Reference a sub form
!From.{formName}.form.{NameOfSubFromObject}.requery

After requery you may lose the selected record. I would make a vaible to hold the current record and use the docmd.findrecord to return to it.

An error that should be anticipated is handling the case when the form is not open.

If currentProject.allforms(“{formName}”).isopen = true then
!Form.{formName}.requery
End if
 
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).
 

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

Back
Top