how do i get the subform to use data from main form

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

Guest

I have a form that uses the project number as the basis for the information.
I have a button on this form that goes to a subform. How do I get the
subform to bring the current project number forward for that form?
 
Klane,

I'm not sure what you mean by a button that "goes to" a subform. A subform
is embedded in the main form, and, if linked by the Project Number would
require no action at all. If you mean that you are opening *another* form
and would like to use the current record as a Filter, use the following code:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourSecondForm"

stLinkCriteria = "[FieldInRecordSourceof2ndForm]=" &
Me![CorrespondingValueFrom1stForm]
DoCmd.OpenForm stDocName, , , stLinkCriteria

If you enable the wizard (View, Toolbox, <toggle on the wand & stars
button>) from form design view, and select Form Operations, Open Form, and
follow the prompts, Access will create the event procedure for you, including
error-handling.

Hope that helps.
Sprinks
 
Back
Top