By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,472 Members | 2,195 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,472 IT Pros & Developers. It's quick & easy.

Subform Record Problem

P: n/a
have a main form with two tabs, and each tab has a subform. The first
tab's subform refers to the mainform (this works). The second tab's
subform refers to the identity key of the first tab's subform.

I can't get the second subform to show the proper records. I have
used the child and masterlink fields. I have set the recordsource of
the second subform to include the identity key field on the first
subform.

This an accounting system and is running many calculations. If I try
to requery the subform using the oncurrent on the first subform it
crashes. I've tried to set the recordsource in different places and
can't get it to work properly.

The closest I came was to put the recordsource dynamically on the
tabmain code. But that only returned one record in the second subform
instead of all the correct records.

At this point I'm stuck. Any help would be appreciated.

Feb 19 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a


How are you setting the Child/Master links between subforms?

Feb 19 '07 #2

P: n/a
Make the subform's recordsource the result of a query. Set the the
query parameter on the matching field main key to subform foreign key.

forms!form1!key_value

in 'criteria' box under the foreign key's column in the query.

Feb 19 '07 #3

P: n/a
On Feb 19, 5:06 pm, "Ecohouse" <ecovinda...@yahoo.comwrote:
have a main form with two tabs, and each tab has a subform. The first
tab's subform refers to the mainform (this works). The second tab's
subform refers to the identity key of the first tab's subform.

I can't get the second subform to show the proper records. I have
used the child and masterlink fields. I have set the recordsource of
the second subform to include the identity key field on the first
subform.
make an unbound field on the parent form called txtKey

Access hates to use an unbound field as master field, you can do it.
Make txtKey your master field for the second (non-working) subform.
You can't use the wizard to build this relationship, and any time you
try to use the wizard it will clear the relationship.

in the first (working) subform's onCurrent event:
me.parent!txKey = me!txtID
Feb 20 '07 #4

P: n/a
Thanks for all the help. I've tried using all of the suggestions and
none of them work. This form is complicated and runs a lot of
calculations and updates when it moves from record to record and
subform to subform.

I put an unbound field on the main form and it caused the form to
crash. I am using the master-child links also and that returns all
the records.

I've also set the recordsource dynamically. This is the closest I've
come. But the problem is that it only returns one record instead of
all of them. This is the code:

Private Sub TabMain_Change()

Dim strsql As String

If Me.Dirty Then Me.Dirty = False

If Me.TabMain.Value = 2 Then
strsql = "SELECT ProjectData.* FROM ProjectData WHERE " & _
"([ProjectData].[EngagementSK]= " & [Forms]!
[ClientInformation]![subEngagementInformation].Form!SK & "); "

Me![subProjectInformation].Form.RecordSource = strsql

Me.subProjectInformation.Form.Refresh
End If

I can't use a requery here because it causes the form to crash. Any
other ideas?

End Sub

Feb 20 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.