473,398 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

One sub form linked to another

I have a basic form. On it are two sub forms. The top sub form has a
list of records. When a user clicks on a new row within the top sub
form. I want the RecordSource of the bottom sub form to change
according to some data in the row of the top sub form.

Main Form Name: Form1
Top Sub Form Name: frmT1_Datasheet
Bottom Sub Form Name: frmT2_Datasheet

The code in frmT1_Datasheet is:

Private Sub Form_Current()
[Forms]![Form1]![frmT2_Datasheet].Form.RecordSource = _
"SELECT * FROM tblT2 WHERE ID = " & Me![Number]
End Sub

IT DOES WORK! HOWEVER...it does not work when first loading Form1. I
get the message, "Run-time error '2455': You entered an expression
that has an invalid reference to the property Form/Report".

I'm guessing that it is because frmT2_Datasheet is not loaded yet.
After it is loaded it works fine.

Is there another way to do this? Or is there a work around?
Nov 13 '05 #1
4 4657
Your description leads me to believe that the RecordSource of the Form
embedded in the first Subform Control is related one-to-many to the data in
the main Form, and that the RecordSource of the Form embedded in the second
Subform Control is related one-to-many to the data in the Form embedded in
the first Subform Control. An appropriate approach to handling such data
would be to embed the second Subform Control in the form embedded in the
first Subform Control, rather than embedding it in the main Form. That will
likely avoid the error you describe.

The expectation would be that the Fields listed in LinkMasterFields are in
the RecordSource of the main Form and the LinkChildFields are in the
RecordSource of the Form embedded in the Subform Control. However, you can
use a reference to a Control -- perhaps you could use this rather than
trying to set the RecordSource of the Form embedded in the Subform Control?

Larry Linson
Microsoft Access MVP

"Paul" <pw****@hotmail.com> wrote in message
news:b8**************************@posting.google.c om...
I have a basic form. On it are two sub forms. The top sub form has a
list of records. When a user clicks on a new row within the top sub
form. I want the RecordSource of the bottom sub form to change
according to some data in the row of the top sub form.

Main Form Name: Form1
Top Sub Form Name: frmT1_Datasheet
Bottom Sub Form Name: frmT2_Datasheet

The code in frmT1_Datasheet is:

Private Sub Form_Current()
[Forms]![Form1]![frmT2_Datasheet].Form.RecordSource = _
"SELECT * FROM tblT2 WHERE ID = " & Me![Number]
End Sub

IT DOES WORK! HOWEVER...it does not work when first loading Form1. I
get the message, "Run-time error '2455': You entered an expression
that has an invalid reference to the property Form/Report".

I'm guessing that it is because frmT2_Datasheet is not loaded yet.
After it is loaded it works fine.

Is there another way to do this? Or is there a work around?

Nov 13 '05 #2
Thanks for your response Larry. I don't completely understand your
post. However, I have a few comments.

First of all, the main form (Form1) has nothing to do with the two sub
forms. It is just a holder for the two sub forms. So there is no
linkage between Form1 and the two sub forms.

Second, both sub forms (frmT1_Datasheet and frmT2_Datasheet) are
datasheet forms. So I cannot embed T2 into T1; unless you meant into
the header or footer of the form. I would prefer not to do that. It
doesn't seem very clean.

With that in mind, would what you said earlier still work?
Nov 13 '05 #3
pw****@hotmail.com (Paul) wrote in
news:b8**************************@posting.google.c om:
I have a basic form. On it are two sub forms. The top sub
form has a list of records. When a user clicks on a new row
within the top sub form. I want the RecordSource of the
bottom sub form to change according to some data in the row of
the top sub form.

Main Form Name: Form1
Top Sub Form Name: frmT1_Datasheet
Bottom Sub Form Name: frmT2_Datasheet

The code in frmT1_Datasheet is:

Private Sub Form_Current()
[Forms]![Form1]![frmT2_Datasheet].Form.RecordSource = _
"SELECT * FROM tblT2 WHERE ID = " &
Me![Number]
End Sub

IT DOES WORK! HOWEVER...it does not work when first loading
Form1. I get the message, "Run-time error '2455': You entered
an expression that has an invalid reference to the property
Form/Report".

I'm guessing that it is because frmT2_Datasheet is not loaded
yet. After it is loaded it works fine.

Is there another way to do this? Or is there a work around?


Yes there is. Create a hidden, unbound textbox on Form1. Let's
call it txtLinker,
In frmT1_Datasheet. put the following code in the form's current
event.

Me.parent.textlinker.value = me.number

Now you can setup the rowsource of frmT2_Datasheet to be SELECT *
FROM tblT2. Just make the link parent fields property to the
txtLinker created above.

--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #4
Thanks Bob! I got it to work.
Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: intl04 | last post by:
How do I create a data input form in Access that is external to the Access database to which it's connected (if that's possible, which I believe it is)? For example, if someone clicks on an Access...
9
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a main form with a continuous subform. On the main form I have a text field called . It gets populated based on what the user selects in a field on the...
3
by: intl04 | last post by:
Is it possible to create a Word form as the data entry form for an Access database? I didn't see any reference to this possibility in my Access books, so I'm sorry if this is a question that is...
4
by: glenhong | last post by:
Hi I need some help here. I am running Access 2003. I have an Access DB linked (Front-end) to another Access DB (Back-end). I have a Form which has a third party grid on it. The grid is...
0
by: weezles | last post by:
hi I'm having trouble with using a linked form instead of a sub form on a 1 to many relationship. Then linked form can be accessed from various other forms. When it opens the linked form, if...
5
by: ortaias | last post by:
I have a form which calls up a second form for purposes of data entry. When closing the data entry form and returning to the main form, things don't work as expected. When I return to the main...
1
by: Doll | last post by:
I need some help please. I need to show data as disabled but visible on 1 of my forms that is linked up to another table. For example: I have 2 forms and 2 tables. Form A is linked to table...
3
by: cyber0ne | last post by:
Probably another easy question... I have two data tables. One holds the main data, the other holds additional data on a many-to-one relationship with the main data. Using the forms wizard, my...
3
by: john | last post by:
I have a form with Members and in that form a subform with Transactions. Those are linked (on banknr) 1xM which I've set in the database relations. Now I would like to copy the form and modify it....
11
beacon
by: beacon | last post by:
Hi everybody, I created a database that links one table from an ODBC data source. I saved my password and UID to the data source so neither myself nor anyone else would have to login each time...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.