Accessing sub forms

A

Adam.Tyson

Dear Access Experts,

I'm using Access 2003 and I'm having the following problem.

I have a form (called MainForm) that contains 2 sub forms (called
SubForm1 and SubForm2).

Both SubForm1 and SubForm2 are datasheet views.

When the selected row changes in SubForm1, I need to change the
RecordSource property in SubForm2. The row changed event I'm capturing
in the Form_Current() sub on SubForm1. I thought I would be able to
access SubForm2 from SubForm1 with something along the lines of:

Private Sub Form_Current()
Me.Parent!Subform2.Form.RecordSource = "select * from mySubTable
where myTableId ='" + Me.myTableId + "'"
End Sub

But, I can't seem to get the syntax correct (assuming such an approach
is possible).

Can someone point me in the right direction?

Thanks,

Adam
 
R

Ron2006

Dear Access Experts,

I'm using Access 2003 and I'm having the following problem.

I have a form (called MainForm) that contains 2 sub forms (called
SubForm1 and SubForm2).

Both SubForm1 and SubForm2 are datasheet views.

When the selected row changes in SubForm1, I need to change the
RecordSource property in SubForm2. The row changed event I'm capturing
in the Form_Current() sub on SubForm1. I thought I would be able to
access SubForm2 from SubForm1 with something along the lines of:

Private Sub Form_Current()
Me.Parent!Subform2.Form.RecordSource = "select * from mySubTable
where myTableId ='" + Me.myTableId + "'"
End Sub

But, I can't seem to get the syntax correct (assuming such an approach
is possible).

Can someone point me in the right direction?

Thanks,

Adam

Here is another approach.

1) On the Main Form place a hidden field perhaps called hldMyTableID.
2) In the OnCurrent event of subform1
forms![MainForm]![hldMyTableID] = me.myTableID

3) In the design mode of subform2 for the form itself place
LinkMaster as [hldMyTableID]
LinkChild as [name of my tableid in that table]

You have to do it by hand because the wizard for linking the tables
will not function. But it is the wizard that does not work...the
actual linking will work.

Ron
 
A

Adam.Tyson

Ron,

Thanks very much for the quick (and more importantly correct!) reply.
That was exactly what I was looking for.
Thanks again,

Adam
 

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