I have a couple of forms in an app I am working on that do exactly this.
There is a main form with 2 separate subforms.
In other words, the second subform is not on the first subform, it is on the
main form in the same way that the first subform is on the main form.
Is this the way yours is set up?
On the main form I have an unbound text box called txtLink.
For the first subform's On Current event, I have
If Me.RecordsetClone.RecordCount > 0 Then
Parent.txtLink = Me.PartID
End If
PartID is the primary key for both subforms.
For the second subform, on its property dialog, on the data tab I have
Link Child Fields PartID
Link Master Fields txtLink
This works very well for me.
I wonder what is different in the way your forms are set up?
Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
channell said:
I apologize and I greatly appreciate your help, but it didn't work, and I
am
sure I am doing something horribly wrong. It now asks me to enter a
parameter value for "txtLink" I am not sure what to do from here. I am
not
good with VBA at all. Thanks
-Scott Channell
Jeanette Cunningham said:
Just remembered that in Northwind you must double click in the 1st
subform
to make it work.
Here is a way to make it happen automatically:
Add a hidden text box named txtLink to the main form's header/footer
section.
Set sfa's Link Master Fields property to txtLink and the Link Child
Fields
property to the corresponding field.
The code in sfb's Current event would only need to be:
Parent.txtLink = Me.thelinkingfield
The rest is automatic.
Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
channell said:
Ok, I got it working for the most part... What is happening right now
is
that
form (a) is now opening in a separate window, but displaying the
correct
information. I don't need it to open in a separate window; I need it
to
automatically change on the form I have opened. Thanks for your help!
:
Tanks a tonf for the help. I have put the information in the "On
Click"
Event as follows:
Private Sub Command62_Click()
DoCmd.OpenForm "f6135MAINENTRYEASY", , , "[6135 ID] = " & Me.ID & ""
End Sub
It is now saying: "Compile error: Method or data member not found"
It is highlighting the "Me.ID" Section of the code.
I am not sure what to do from here. Thanks a lot again!
-Channell
:
Hi channell,
Put the button on subform b
Put code like this:
Private sub btnB_Click()
DoCmd.OpenForm "frmA", , , "[ID] = " & Me.ID & ""
End Sub
btnB is the name of the button on form b.
frmA is the name of the form with the single record.
ID is the name of the primary key field of each record on frm b.
Replace those names with appropriate names for your forms.
Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
I want to thank anyone in advance for helping me out.
I have a form with a 2 subforms. The main form has a combo box
which
looks
up a name of a person. The subforms then display information
about
the
person I selected. The two subforms are alomst identicle except
one
(a)
is a
single for (which you can select through the various records with
the
navigation buttons), and the other form (b) displays continuous
records
with
abreviated info on it. Now, I want to put a button on every
listed
record
on
form (b) that returns the same record in form (a).
I hope I explained clearly. Thank you so much for your help.