Linking Sub Forms

M

Mixer1

I am really missing something on some basic of sub forms. I need help.

I want to set up a form that has two subforms. The form will not conatin
anything. One subform will be the names of every item in the table in a
comtiusous form.

As someone clicks their mouse on one item in the continsuous form, I want
details of that item to shou up in a second subform, in individual form

Both subforms will be based on info in the same table, even!

Where in the second subform, the one with all the details to I tell it to lo
look at what item is selected in the firsat subform.

As I move up and down the contiuous form on the left, I want the details of
that item to show up on the ind. form on the right.

Thanks. Be nice, I'm sortof new at this. Can't you tell??
 
J

Jeff Boyce

There may be an easier way to get a set of "details" loaded into a form,
based on a selection...

When I need to do this, I create a form based on a query, the query based on
the table. This is just a starting point. This form, as described, is
loaded with ALL the rows of data, and you could scroll through it (but that
isn't a very easy way to find records).

Next, I add an unbound combobox (i.e., it doesn't refer to any of the fields
in the query) in the header of the form. For the Row Source of the
combobox, I use a (small) query that only returns the RowID and one (or two)
of the fields from the table, used only to help me identify WHICH row I want
to look at the details on.

Then I modify that first query to "point" to the combobox on the form for a
Selection Criterion for the RowID field (in other words, telling the query
to find the row that has the RowID in the combobox). To get this to work, I
also have to tell the combobox to re-run the query to re-load the form. In
the combobox's AfterUpdate event, I add:
Me.Requery

Now, when I open the form, there's nothing in the combobox, so the query
that loads the form has no RowID and returns that record (i.e., no record).
I select one of the items from the combobox and tab out of the control, and
the combobox's AfterUpdate tells the form to requery its source ... and now
the query DOES have a (selected) row and returns that to the form.

I realize this might sound like a lot of work, but trying to get two
continuous form subforms to coordinate and do the same thing will be even
MORE work!

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
M

Mixer1

Jeff,

Thanks for the response. Sorry it took me so long to get back.

I need to stay with 2 subforms linked to each other and not parent--child. I
found out that I cant use a continuous form as a sunform, and one of the
forms is a subform.

Subform1 is the cont. form, subform2 is a individual form.

I got this to work with help from others . . . sortof.
In the On current of subform1 I put:

Me.Parent.Subform2.Form.Filter = "IDName = '" & Me.[IDName] & "'"
Me.Parent.Subform2.Form.FilterOn = True

It works. But when the form loads initially I get a 2455 error "Yopu
entrered an expression that has a invalid reference to the property
Form/Report.

Debug takes me to the first line of that code. But if I end raterh than
debud, the form loads fine and switching between records in the cont form
(subform1) changes the indivudual item in suform2.

So, I'm almost thhere. But what do I have that it doesn't. The field is
present in both queries and it is a text field.

Thanks for the help
 
M

Mixer1

In my first paragraph I saif one of my forms is a subform. I meant one of my
forms I need as a subform is a Continuous form.
 
J

Jeff Boyce

Sorry I couldn't help more. I haven't done it the way you are trying to...

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
M

Mixer1

Ok. Thanks.

Like I said, it works. I just have to say no to error and there it is, all
linked up fine. I'll get it nailed down eventually. Thanks
 
M

Mixer1

I think the error was related to one subform running code before the other
subform opens. So, thanks to someone in another forum . . . . .

Private Sub Form_Current()
On Error GoTo EH
Me.Parent.frmMainSub2.Form.Filter = "IDName = '" & Me.[IDName] & "'"
Me.Parent.frmMainSub2.Form.FilterOn = True
Exit Sub
EH:
If Err.Number = 2455 Then
Exit Sub
Else
MsgBox "Error " & Err.Number & ": " & Err.Description
End If
 

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

Top