specifying a field in a table in a Tab on a Parent form

  • Thread starter BBC via AccessMonster.com
  • Start date
B

BBC via AccessMonster.com

I have a number of tables (in the form of dataSheets but they are not
subforms) on a single TAB control (one tabel per tab number) on my Parent
form. Some of the fields on the Child (TAB) tables are "lookup" (comboboxes)
as specified in the table's original properties. I would like to be able to
change these lookups "on the fly" so would like to move them into code. I am
not sure how to code the VBA necesary to access/set the RowSource
programatically (not sure where either, but assuming when I load the Parent
form).

I have a module (called cboPopUp("the_table_code") that sets the rowsource
for all my popups.
Ex. Me.Gender.RowSource=cboPopUp("Gender") ' sets up all entries
idcode="gender"

I would like to use this same technique for the popup fields on the
datasheets rather than specifying them in the table setup properties (lookup
tab). Sorta Pseudo code like maybe

Me.Tabname/Tabnumber.tabelname.fieldname.rowsource=cbopopup("gender")

thoughts ?
 
M

Marshall Barton

BBC said:
I have a number of tables (in the form of dataSheets but they are not
subforms) on a single TAB control (one tabel per tab number) on my Parent
form. Some of the fields on the Child (TAB) tables are "lookup" (comboboxes)
as specified in the table's original properties. I would like to be able to
change these lookups "on the fly" so would like to move them into code. I am
not sure how to code the VBA necesary to access/set the RowSource
programatically (not sure where either, but assuming when I load the Parent
form).

I have a module (called cboPopUp("the_table_code") that sets the rowsource
for all my popups.
Ex. Me.Gender.RowSource=cboPopUp("Gender") ' sets up all entries
idcode="gender"

I would like to use this same technique for the popup fields on the
datasheets rather than specifying them in the table setup properties (lookup
tab). Sorta Pseudo code like maybe

Me.Tabname/Tabnumber.tabelname.fieldname.rowsource=cbopopup("gender")

Sorry, but I do not follow what you are trying to do, but a
couple of comments might be useful. The fact that a subform
is in a tab control has nothing to do with much of anything,
so you can ignore that as a complication.

If tabelname is the name of the subform control on the main
form (it could be different from the name of the "table"
being displayed), then I think your reference would be more
like:

Me.tabelname.Form.fieldname.rowsource=cbopopup("gender")

Note that part of my confusion about your description is
your use of the words "table" and "field". A table is
displayed in a (sub)form and tables/querys have fields
(columns) while forms/reports have controls. Usually, it's
clear from the context which is which, but here I can't tell
if you are talking about a field in a table or a control on
a form.
 
B

BBC via AccessMonster.com

I don't actually have or at least didn't set up "subforms" on the TABs, I
simply dragged a different table (a child of the main part of the form) onto
each TAB which gave me a datasheet view of that child table (sync'd with the
main part of the form). This part works fine as do the fields defined as
popup/lookups in the table definition.

But now I want more control over the popups so wanted to set them
programitically (in VBA as per below's cboPopUp() ). So, given these are the
actual tables (datasheets) on the tabs, not "subforms" per se', I'm not sure
how to reference them and set their properties such as .rowsource, or for
that matter if I even can do it.
I know I can do what I want if I define a subform for each of the tables and
put each of the subforms on a tab - I've done that elsewhere, but this form
is from earlier, less experienced days.
In retrospect, that is probably what I should as done (and may just do now)
as I know that works and I can control the PopUps.
That been said I would still like to know if I can (and how I would)
reference fields in the situation I originally described.
Thanks and sorry for the lack of clarity

Marshall said:
I have a number of tables (in the form of dataSheets but they are not
subforms) on a single TAB control (one tabel per tab number) on my Parent
[quoted text clipped - 15 lines]
Me.Tabname/Tabnumber.tabelname.fieldname.rowsource=cbopopup("gender")

Sorry, but I do not follow what you are trying to do, but a
couple of comments might be useful. The fact that a subform
is in a tab control has nothing to do with much of anything,
so you can ignore that as a complication.

If tabelname is the name of the subform control on the main
form (it could be different from the name of the "table"
being displayed), then I think your reference would be more
like:

Me.tabelname.Form.fieldname.rowsource=cbopopup("gender")

Note that part of my confusion about your description is
your use of the words "table" and "field". A table is
displayed in a (sub)form and tables/querys have fields
(columns) while forms/reports have controls. Usually, it's
clear from the context which is which, but here I can't tell
if you are talking about a field in a table or a control on
a form.
 
J

John W. Vinson

I don't actually have or at least didn't set up "subforms" on the TABs, I
simply dragged a different table (a child of the main part of the form) onto
each TAB which gave me a datasheet view of that child table (sync'd with the
main part of the form). This part works fine as do the fields defined as
popup/lookups in the table definition.

When you dragged tables onto the form, Access "helpfully" created Subforms for
you... so you DO have subforms on the tabs.

A Form can only have one Recordsource. If you're putting multiple tables onto
a form, you can only do so by using Subforms, or by basing the Form on a
multitable query (which must be created separately, not by dragging table
icons).
 
M

Marshall Barton

BBC said:
I don't actually have or at least didn't set up "subforms" on the TABs, I
simply dragged a different table (a child of the main part of the form) onto
each TAB which gave me a datasheet view of that child table (sync'd with the
main part of the form). This part works fine as do the fields defined as
popup/lookups in the table definition.

But now I want more control over the popups so wanted to set them
programitically (in VBA as per below's cboPopUp() ). So, given these are the
actual tables (datasheets) on the tabs, not "subforms" per se', I'm not sure
how to reference them and set their properties such as .rowsource, or for
that matter if I even can do it.
I know I can do what I want if I define a subform for each of the tables and
put each of the subforms on a tab - I've done that elsewhere, but this form
is from earlier, less experienced days.
In retrospect, that is probably what I should as done (and may just do now)
as I know that works and I can control the PopUps.
That been said I would still like to know if I can (and how I would)
reference fields in the situation I originally described.


It seems that you are using A2007 where dragging and
dropping a table/query automatically creates a datasheet
subform to display the data.

Regardless of how you created the subform, I still think
it's possible my earlier suggetion will do what you want.
 
B

BBC via AccessMonster.com

Thanks a lot
What you say makes sense.

I will give your method
Me.tabelname.Form.fieldname.rowsource=cbopopup("gender")
a try

Marshall said:
I don't actually have or at least didn't set up "subforms" on the TABs, I
simply dragged a different table (a child of the main part of the form) onto
[quoted text clipped - 14 lines]
That been said I would still like to know if I can (and how I would)
reference fields in the situation I originally described.

It seems that you are using A2007 where dragging and
dropping a table/query automatically creates a datasheet
subform to display the data.

Regardless of how you created the subform, I still think
it's possible my earlier suggetion will do what you want.
 

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