Two subforms for the same table

A

alexasha

I have set up two tables. One is the list of patients (Table 1) and another
patiens encounters (table 2). Both tables are linked by records number.
I have created a form with data from table 1 in justified view. On the same
form I have added tab controle and inserted form created for Table 2 and
Table 2 itself as two subforms in the same tab. I have ended up with a
tabulated view of Table 2 (basically list of all encounter for that patients)
and justified view of form for Table 2, where I can enter my data or edit
existing data.

What I want to do is to be able to click on record on tabulated Table 2 and
to be able to view it in justified form of table 2.

In addition, entering data in either of the forms will not show data in
another forms unless I restart my form.

I hope you can help me. THanks
 
R

RuralGuy

I have set up two tables. One is the list of patients (Table 1) and
another patiens encounters (table 2). Both tables are linked by records
number. I have created a form with data from table 1 in justified view.
On the same form I have added tab controle and inserted form created for
Table 2 and Table 2 itself as two subforms in the same tab. I have ended
up with a tabulated view of Table 2 (basically list of all encounter for
that patients) and justified view of form for Table 2, where I can enter
my data or edit existing data.

What I want to do is to be able to click on record on tabulated Table 2
and to be able to view it in justified form of table 2.

In addition, entering data in either of the forms will not show data in
another forms unless I restart my form.

I hope you can help me. THanks

Hi alexasha,

How many places did you post this? Here is how I answered it elsewhere.
____________________________________________________
In the AfterUpdate event of all of the controls that may be changed, put
something like the following:

Me.Parent.SubFormControl2.Form.Refresh

Change the "SubFormControl2" to the name of your SubFormControl2

This is not the SubForm but the SubFormControl!
______________________________________________________

When I think about it you could probably put it in the AfterUpdate event of
the SubForm and catch all of the controls changing data. You would have to
put the reciprical in the other SubForm so that changing data in either
SubForm would be visible on the other. If you are adding records to either
Subform then you will need a Requery rather than the Refresh.

hth
 
A

alexasha

Thanks for answering it again, I appologise for duplication of questions.
Placing:
Me.Parent.SubFormControl2.Form.Refresh
in property of one of the subforms did the trick actually for both subforms.
I am not very clear about Requery. What it would do, and shoud I type:
Me.Parent.SubFormControl2.Form.Requery
And then, if yes, would it also reflesh updated old records?

Second part that I am still very unclear is how by clicking on the record in
tabulated subform form to display that record in justified subform
Again, great thanks for your help
 
R

RuralGuy

Thanks for answering it again, I appologise for duplication of
questions. Placing:
Me.Parent.SubFormControl2.Form.Refresh
in property of one of the subforms did the trick actually for both
subforms. I am not very clear about Requery. What it would do, and shoud
I type:
Me.Parent.SubFormControl2.Form.Requery
And then, if yes, would it also reflesh updated old records?

Second part that I am still very unclear is how by clicking on the
record in tabulated subform form to display that record in justified
subform Again, great thanks for your help

Refresh will update all of the records in the current recordset. Requery
actually fetches a brand new resordset with any additional records that
have been added. Refresh would not pick up any new records.

I'm sorry but I don't understand the second part of your question.

hth
 
R

RuralGuy

Second part that I am still very unclear is how by clicking on the
record in tabulated subform form to display that record in justified
subform Again, great thanks for your help

I am unfamiliar with the terms "tabulated" and "justified" in reference to
forms or subforms. Could you explain further or use other words? Are these
Single Form View and Continuous Form View?
 
R

RuralGuy

Hi alexasha,

Does Table 2 have a unique field in each record, like maybe an autonumber?
 
A

alexasha

Yes, table 2 have a unique field (autonumber)
Tabulated view in the form is basically table inserted into the form, where
all the records are in the rows. That allows me to see the whole table (all
records) in the forms. Justified view is a view where I can see only one
record and fields are arranged in a justified manner.

What I want to do is to select a record in the tabulated view (basically
select a row in table) and view that particular record in my justified
subform. Again, both forms are on the same page, which make is very
convinient. I hope this is a littly bit clearer. I would love to upload
screenshot of the table setup, but can not find this option on this forum.
 
R

RuralGuy

Yes, table 2 have a unique field (autonumber)
Tabulated view in the form is basically table inserted into the form,
where all the records are in the rows. That allows me to see the whole
table (all records) in the forms. Justified view is a view where I can
see only one record and fields are arranged in a justified manner.

What I want to do is to select a record in the tabulated view (basically
select a row in table) and view that particular record in my justified
subform. Again, both forms are on the same page, which make is very
convinient. I hope this is a littly bit clearer. I would love to upload
screenshot of the table setup, but can not find this option on this
forum.

Hi alexasha,

Excellent. You need to set the 'Link Master Field' of the "justified
subform" to the AutoNumber field of the "tabulated subform". Something
like: SubFormControl1Name.Form.ControlBoundToTheAutonumberField.

Obviously replace my PsudoNames with your actual names. If you don't mind
me asking, what language is your Access in?

hth
 
A

alexasha

It is US version
You need to set the 'Link Master Field' of the "justified
subform" to the AutoNumber field of the "tabulated subform". Something
like: SubFormControl1Name.Form.ControlBoundToTheAutonumberFie

Both of the subforms belong to the same table. So How can I this. Where do I
insert the above statement. If I will create addition field, then it would
appear in both subforms. Again, thanks for your patience with me.
 
R

RuralGuy

It is US version
You need to set the 'Link Master Field' of the "justified
subform" to the AutoNumber field of the "tabulated subform". Something
like: SubFormControl1Name.Form.ControlBoundToTheAutonumberFie

Both of the subforms belong to the same table. So How can I this. Where
do I insert the above statement. If I will create addition field, then
it would appear in both subforms. Again, thanks for your patience with
me.

The additional TextBox control bound to the AutoNumber field need *not* be
visible. You can hide it behind another control or set its visible property
to False.

The "code" belongs in the "Link Master Fields" and "Link Child Fields" of the
"justified subform" SubFormControl. This is *not* the SubForm but the
SubFormControl that displays the SubForm on the main form.

hth
 
A

alexasha

I am so sorry for being completely stupid.
Where do I find this
Link Master Fields" and "Link Child Fields" of the "justified subform"
SubFormControl.
I created new text box and made it invisible. After that I am completely lost.
 
R

RuralGuy

I am so sorry for being completely stupid.
Where do I find this
Link Master Fields" and "Link Child Fields" of the "justified subform"
SubFormControl.
I created new text box and made it invisible. After that I am completely
lost.

Sometimes they can be a little difficult to get to. On your Main form (I
will call it Form1) you said you display at least 2 SubForms. These are
displayed using "SubFormControls". Left click on the "justified subform"
such that the little box in the upper left corner of the SubForm has the
dark box in it. Now click on the edge of the control so that the dark box
goes away and there are pull points on the SubFormControl where you could
change the size if you wanted to. Move your cursor to the upper left
corner of the SubformControl 'til it changes to a hand and right click and
bring up the property sheet of the SubFormControl.

Go to the Data tab of this property sheet and if you are on the
SubFormControl you will see "Source Object", "Link Child Fields", "Link
Master Fields" top down.

hth
 
A

alexasha

Great I got to properties and see all controls. Where do I insert the code. I
have tried to replace my Link Marster Field with code
Encounter_New.Form.ControlBoundToAutoID_Med
But it did not go really well (did not work)
 
R

RuralGuy

Great I got to properties and see all controls. Where do I insert the
code. I have tried to replace my Link Marster Field with code
Encounter_New.Form.ControlBoundToAutoID_Med
But it did not go really well (did not work)

Great! We're making progress! What are the actual names of the two
SubFormControls? Label them "justified" and "tabulated" for me so I know
what you mean. What is the actual name of the control that is bound to the
AutoNumber?
 
A

alexasha

Medication_justified
Medication_Tabular
AutoID_med is an autonumber field
Medication table linked to main table with medical record
Thanks
 
R

RuralGuy

Medication_justified
Medication_Tabular
AutoID_med is an autonumber field
Medication table linked to main table with medical record
Thanks

In the Medication_justified SubFormControl properties set the following:

Link Master Fields = Medication_Tabular.Form.AutoID_med
Link Child Fields = AutoID_med

See how that works!
 
A

alexasha

Well, I am getting error enter parameter box.
both link master fields and link child fields are linked to main table with
medical record number. Removing this I wil be losing link between two tables.
Both Medication_justified and Medication_Tabulated refer to the same table
<medication>, they just designed in different ways. Tabulated show all
records available for the paticular person, justified allows me to see just
one record. But Mecication is linked to main table with demographics for that
person.
 
R

RuralGuy

Hi alexasha,

For future reference AFAIK forms can only be displayed 5 ways:

1) Single Form
2) Continuous Forms
3) DataSheet
4) Pivot Table
5) Pivot Chart

This information can be found on the Format tab of the property sheet of
the actual SubForm next to the Default View (item number 2 from the top).

With your description of "justified" and "Tabular" I could still be all wet
trying to understand your form construction.

It makes it a lot easier if we can all use a common language - in this case
English Access! :)
 
R

RuralGuy

Well, I am getting error enter parameter box.
both link master fields and link child fields are linked to main table
with medical record number. Removing this I wil be losing link between
two tables. Both Medication_justified and Medication_Tabulated refer to
the same table <medication>, they just designed in different ways.
Tabulated show all records available for the paticular person, justified
allows me to see just one record. But Mecication is linked to main table
with demographics for that person.

What we want to do is link the justified subform to the tabulated subform
via the autonumber field in the <medications> table. We will then have the
tabulated subform linked to the main form by patient or whatever and the
justified subform linked to the other subform. Both subforms will be
linked to the main form but one will be indirectly.

Parameter boxes popping up usually means you are not using the same name or
you did not type it correctly.

hth
 
A

alexasha

Justified ended up being single form
Tabulated - Continuous Forms

I had refered to tabulated and justified in reference to form Wizard. Sorry
for the confusion. Now I will know.
 

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