473,385 Members | 1,740 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,385 software developers and data experts.

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 9505
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******@pcdatasheet.com
www.pcdatasheet.com
"Zeeshan Iqbal via AccessMonster.com" <fo***@AccessMonster.com> wrote in
message news:3e******************************@AccessMonste r.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.com" <fo***@AccessMonster.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.net
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.com"
<fo***@AccessMonster.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 bolAllowOnCurrent = False then
exit sub
end if

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

me.MySubForm.Form.SetCurrentOn

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

Public Function SetCurrentOn

bolAllowOnCurrent = 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 bolAllowOnCurrent = False then
exit sub
end if

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

me.MySubForm.Form.SetCurrentOn

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

Public Function SetCurrentOn

bolAllowOnCurrent = True

end function.

Anyway...your 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.com...
On Mon, 15 Nov 2004 08:03:32 GMT, "Albert D. Kallal"
<Pl*******************@msn.com> wrote:
Anyway...your 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.dabba.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...your 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.com...
On Mon, 15 Nov 2004 12:07:05 GMT, "rkc" <rk*@yabba.dabba.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...your 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.dabba.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.dabba.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...your 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
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...
3
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...
1
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...
2
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...
0
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...
5
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...
8
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...
0
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...
4
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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,...
0
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...

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.