add a linked record from a form

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

Guest

Is there a way to link the info on two forms like a subform when opening
another form with the first form open? I want to use a form to enter info
then open another form and link it to the first form. I am using access 2k
..adp as a front end to sql.

Thanks for any help.
 
1slogan,

Much easier to use a subform...Access does all the work for you.
Haven't actually tried this, but it should work:

Given in code below Form1 is the "main" form and Form2 is the "sub" form and
field "RecKey" is used to link the two data sources:

In the Current event of Form1:

'If second form is not open, open it. Notice it is being opened
' without a filter and NOT as a Dialog.
If Not IsLoaded("Form2") Then
DoCmd.OpenForm "Form2"
'Set focus back on main form.
Forms("Form1").AnyActiveControl.SetFocus
End If

'Set filter on second form.
Forms("Form2").Filter = "RecKey = " & Me.RecKey
Forms("Form2").FilterOn = True

HTH,
Bruce
 
Back
Top