473,772 Members | 2,513 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to connect two subforms

hi,
im trying to design a form with two subforms. subforms no.1 (orders) is connected to the main form by customer ID and i dont know how i can connect another subform (order details)to the first subform(orders) , so that when i enter a customer id i get the orders related to that customer in subform no.1 and order details related to that order in subform no.2. please message me if some one knows how to do that

*************** *************** ***********
* This message was posted via http://www.accessmonster.com
*
* Report spam or abuse by clicking the following URL:
* http://www.accessmonster.com/Uwe/Abu...3a020421f80e27
*************** *************** ***********
Nov 13 '05 #1
9 9535
Treat subform1 as a main form and make subform2 a subform of subform1. Then
click on Windows - Tile Vertically and click and drag subform1 onto your
main form.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdata sheet.com
www.pcdatasheet.com
"Zeeshan Iqbal via AccessMonster.c om" <fo***@AccessMo nster.com> wrote in
message news:3e******** *************** *******@AccessM onster.com...
hi,
im trying to design a form with two subforms. subforms no.1 (orders) is connected to the main form by customer ID and i dont know how i can connect
another subform (order details)to the first subform(orders) , so that when i
enter a customer id i get the orders related to that customer in subform
no.1 and order details related to that order in subform no.2. please message
me if some one knows how to do that
*************** *************** ***********
* This message was posted via http://www.accessmonster.com
*
* Report spam or abuse by clicking the following URL:
* http://www.accessmonster.com/Uwe/Abu...148c3a020421f8
0e27 *************** *************** ***********

Nov 13 '05 #2
Create an invisible, unbound text box on the main form. Use the
OnCurrent event of the Orders subform to populate the textbox with the
value of the PrimaryKey of the Orders subform. Use the textbox as the
Link to your OrderDetail subform.

On Sun, 14 Nov 2004 21:54:14 GMT, "Zeeshan Iqbal via
AccessMonster.c om" <fo***@AccessMo nster.com> wrote:
hi,
im trying to design a form with two subforms. subforms no.1 (orders) is connected to the main form by customer ID and i dont know how i can connect another subform (order details)to the first subform(orders) , so that when i enter a customer id i get the orders related to that customer in subform no.1 and order details related to that order in subform no.2. please message me if some one knows how to do that

************** *************** ************
* This message was posted via http://www.accessmonster.com
*
* Report spam or abuse by clicking the following URL:
* http://www.accessmonster.com/Uwe/Abu...3a020421f80e27
************** *************** ************

*************** *******
ja************* *@telusTELUS.ne t
remove uppercase letters for true email
http://www.geocities.com/jacksonmacd/ for info on MS Access security
Nov 13 '05 #3
On Sun, 14 Nov 2004 21:54:14 GMT, "Zeeshan Iqbal via AccessMonster.c om"
<fo***@AccessMo nster.com> wrote:
hi,
im trying to design a form with two subforms. subforms no.1 (orders) is connected to the main form by customer ID and i dont know how i can connect another subform (order details)to the first subform(orders) , so that when i enter a customer id i get the orders related to that customer in subform no.1 and order details related to that order in subform no.2. please message me if some one knows how to do that

************** *************** ************
* This message was posted via http://www.accessmonster.com
*
* Report spam or abuse by clicking the following URL:
* http://www.accessmonster.com/Uwe/Abu...3a020421f80e27
************** *************** ************


First, if there's some way you can get your news interface to wrap text, that
would be really helpful. What most of us see is one veeryyyyyy looong line
with your entire question in it.

What your asking for is a pattern I use often because it's the only way to
display a one-to-many relationship on a form where both tables are shown as
continuous, multi-row. It's not hard to do, there's just a little trick to
making it work.

First, you need to know that it's possible to use a control name as the master
in the master/child link. It doesn't need to be a field in a table. That
means you can place an unbound control on the container form, and link the
second subform based on the name of that controls.

Next, you need some way to get the value of the control on the container form
to be the id of the current record in the first subform. You do that using
the OnCurrent event handler of the first subform, and copying the value of the
id to the field on the container (its parent).

There's one final issue, though, and that is that the subforms are initialized
-before- the parent, so the first time the Current event fires, it will fail.
You can use On Error Resume next to ignore the error, but then the id control
in the container won't be initialized until the user moves to a new record.

The way I get around this is that the OnOpen handler of the first subform
copies its RecordSource to a variable, and sets the Recordsource to a blank
string. The OnCurrent handler checks the length of RecordSource, and exists
without doing anything if it's zero. The subform also has a procedure the
container form can call to restore the RecordSoruce property from the
variable, and the container calls that method of the subform in its own OnOpen
handler. That causes the subform's OnCurrent to fire for the first row, that
sets the value of the Id control on the container, and that causes the correct
related records to appear in the child second subform.
Nov 13 '05 #4
>The way I get around this is that the OnOpen handler of the first subform
copies its RecordSource to a variable, and sets the Recordsource to a blank
string. The OnCurrent handler checks the length of RecordSource, and exists
without doing anything if it's zero

That is a interesting solution. I in the past usually just use a bolVar in
the sub-form

Then, in on current, I go:
if bolAllowOnCurre nt = False then
exit sub
end if

I then in my main form, at the right time (say on-load) I go:

me.MySubForm.Fo rm.SetCurrentOn

Of couse, in every sub-form, I have:

Public Function SetCurrentOn

bolAllowOnCurre nt = True

end function.

Anyway...your approach is different and interesting....

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl************* ****@msn.com
http://www.attcanada.net/~kallal.msn
Nov 13 '05 #5
On Mon, 15 Nov 2004 08:03:32 GMT, "Albert D. Kallal"
<Pl************ *******@msn.com > wrote:
The way I get around this is that the OnOpen handler of the first subform

copies its RecordSource to a variable, and sets the Recordsource to a blank
string. The OnCurrent handler checks the length of RecordSource, and exists
without doing anything if it's zero

That is a interesting solution. I in the past usually just use a bolVar in
the sub-form

Then, in on current, I go:
if bolAllowOnCurre nt = False then
exit sub
end if

I then in my main form, at the right time (say on-load) I go:

me.MySubForm.F orm.SetCurrentO n

Of couse, in every sub-form, I have:

Public Function SetCurrentOn

bolAllowOnCurre nt = True

end function.

Anyway...you r approach is different and interesting....


With your approach, I don't see how you get the first record ID since the
first Current event has already fired when SetCurrentOn is called. I use the
RecordSource property because setting it causes a Current even to fire. I
could just call Form_Current directly from the method to force it, but it
seems ugly to add new pathways to event vectors.
Nov 13 '05 #6
rkc

"Steve Jorgensen" <no****@nospam. nospam> wrote in message
news:rg******** *************** *********@4ax.c om...
On Mon, 15 Nov 2004 08:03:32 GMT, "Albert D. Kallal"
<Pl************ *******@msn.com > wrote:
Anyway...you r approach is different and interesting....


With your approach, I don't see how you get the first record ID since the
first Current event has already fired when SetCurrentOn is called. I use

the RecordSource property because setting it causes a Current even to fire. I
could just call Form_Current directly from the method to force it, but it
seems ugly to add new pathways to event vectors.


What makes it not a new pathway to the Form_Current event?

Nov 13 '05 #7
On Mon, 15 Nov 2004 12:07:05 GMT, "rkc" <rk*@yabba.dabb a.do.rochester. rr.bomb>
wrote:

"Steve Jorgensen" <no****@nospam. nospam> wrote in message
news:rg******* *************** **********@4ax. com...
On Mon, 15 Nov 2004 08:03:32 GMT, "Albert D. Kallal"
<Pl************ *******@msn.com > wrote:

>Anyway...you r approach is different and interesting....


With your approach, I don't see how you get the first record ID since the
first Current event has already fired when SetCurrentOn is called. I use

the
RecordSource property because setting it causes a Current even to fire. I
could just call Form_Current directly from the method to force it, but it
seems ugly to add new pathways to event vectors.


What makes it not a new pathway to the Form_Current event?


I said Event Vector. I'm forcing the event to occur, not calling the event
handler when the event did not occur. In any case, I'm not saying it would be
wrong to do it the other way, but I was wondering if/how the id gets to the
container form when doing neither of these things.
Nov 13 '05 #8
rkc

"Steve Jorgensen" <no****@nospam. nospam> wrote in message
news:ag******** *************** *********@4ax.c om...
On Mon, 15 Nov 2004 12:07:05 GMT, "rkc" <rk*@yabba.dabb a.do.rochester. rr.bomb> wrote:

"Steve Jorgensen" <no****@nospam. nospam> wrote in message
news:rg******* *************** **********@4ax. com...
On Mon, 15 Nov 2004 08:03:32 GMT, "Albert D. Kallal"
<Pl************ *******@msn.com > wrote:
>Anyway...you r approach is different and interesting....

With your approach, I don't see how you get the first record ID since the first Current event has already fired when SetCurrentOn is called. I use
the
RecordSource property because setting it causes a Current even to fire.

I could just call Form_Current directly from the method to force it, but it seems ugly to add new pathways to event vectors.


What makes it not a new pathway to the Form_Current event?


I said Event Vector. I'm forcing the event to occur, not calling the

event handler when the event did not occur. In any case, I'm not saying it would be wrong to do it the other way, but I was wondering if/how the id gets to the container form when doing neither of these things.


To me a vector is an array, so I guess don't understand the term event
vector.
Nov 13 '05 #9
On Mon, 15 Nov 2004 22:07:30 GMT, "rkc" <rk*@yabba.dabb a.do.rochester. rr.bomb>
wrote:

"Steve Jorgensen" <no****@nospam. nospam> wrote in message
news:ag******* *************** **********@4ax. com...
On Mon, 15 Nov 2004 12:07:05 GMT, "rkc"

<rk*@yabba.dab ba.do.rochester .rr.bomb>
wrote:
>
>"Steve Jorgensen" <no****@nospam. nospam> wrote in message
>news:rg******* *************** **********@4ax. com...
>> On Mon, 15 Nov 2004 08:03:32 GMT, "Albert D. Kallal"
>> <Pl************ *******@msn.com > wrote:
>
>> >Anyway...you r approach is different and interesting....
>>
>> With your approach, I don't see how you get the first record ID sincethe >> first Current event has already fired when SetCurrentOn is called. Iuse >the
>> RecordSource property because setting it causes a Current even to fire.I >> could just call Form_Current directly from the method to force it, butit >> seems ugly to add new pathways to event vectors.
>
>What makes it not a new pathway to the Form_Current event?


I said Event Vector. I'm forcing the event to occur, not calling the

event
handler when the event did not occur. In any case, I'm not saying it

would be
wrong to do it the other way, but I was wondering if/how the id gets to

the
container form when doing neither of these things.


To me a vector is an array, so I guess don't understand the term event
vector.


Sorry - vector has multiple meanings. When talking about events, a vector is
what triggers the event.
Nov 13 '05 #10

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

Similar topics

1
7473
by: JJMM | last post by:
Hi, I have a form (form1) with a large number of subforms inside it (around 20 subforms), There is the possibility of filtering the data using a pop-up form that create/change a query (all the subforms are linked to that query), Once that I create/change the query (using the pop-up form), Is there any easy way to update all the 20 subforms inside form1?. Normally I use to change the recordsource in each subform to show the
3
4004
by: Evil | last post by:
Hi, i have a problem with a treeview and some subforms in MS Access97. I have a form with a treeview on the left side which lets me navigate thru some projects. Then on the right side, i have several Tabs, each with a subform. Now, my tree view nodclick code goes like: sProjNum = me.tvwX.SelectedItem.Key
1
2994
by: M Wells | last post by:
Hi All, I am developing an Access 2003 project application with the back end in SQL Server 2003. I have a master form that tracks projects, and several subforms on it that track various aspects of the project. On the masterform I have two unbound listboxes that I populate with information regarding the current record in one of the subforms.
2
3004
by: Jack | last post by:
Hi all, I searched the archives and found everyone happy with Stephen's MouseWheel On/Off code except for those with subforms. Stephen's page indicates that he has added code to handle subforms ("Bug Fix for SubForms with ScrollBars. Bug fix for SubForms without visible ScrollBars.") - BUT I still can't get it to work on my app with my subforms. I'm using Access 2000, It works fine on the main forms but not on the
0
2244
by: Jack | last post by:
Gday everyone, I'm dearly hoping Stephen Lebans is going to update his masterpeice to stop the mouse wheel scrolling to work on subforms *he has indicated this to me but of course beggers can't be choosers here so I have no idea when this would be done*. I'm just wondering if anyone has gotten around the problem some other way? --Original Thread---
5
2638
by: Richard Stanton | last post by:
Hello all My database has a main form linked to table1. It has several subforms on the main form, all linked to table2. Table1 and Table2 are linked by primary/foreign key, no duplicates allowed, one-to-one. If I update field(s) on a single subform it works fine but when I update fields on multiple subforms ie without closing the form between updates, I get the following error:
8
3092
by: Zlatko Matiæ | last post by:
Hello. How can I synchronize subforms content with current record in master form, if both form and subform are based on DAO code ? I assigned DAO recordset to forms by using QueryDef, on Load event. Thanks...
0
1198
by: Giorgos Louloudis via AccessMonster.com | last post by:
I have tried to do what i found in a message to connect to subforms.I placed an unbound text box in the main form and on the oncurrent event of the one subform i say to copy the id to that text box. The problem is that when i try to link the other subform with the main form the text box does not appear.The only fields that appear are the fields of the table that is related with the main form.How can i link the text box with the second...
4
6058
by: Harlequin | last post by:
I have a question concerning the need to trigger events within a "child" subform which is itself enbedded within a master "parent" form and which is accessible via a tab in the parent form. Becuase this is all very difficult to explain in words, please bear with me as I endevour to explain what it is I am trying to do. It would be helpful if I could attach a graphics file to this posting that would help explain what it is I'm trying to achieve...
0
9621
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7461
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2851
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.