Binding a form to a subform - newby

  • Thread starter Thread starter Ilan
  • Start date Start date
I

Ilan

I was wondering what's the correct way of binding forms. Here is what I do:

Say I have two tables with 1-to-many relationship as follows.

tblAxes
AxisName[PK1]

tblCountries
AxisFK [PK1]
CountryName [PK2]

I want to have a mainform/subform as follows. User selects the Axes name
from a combo box on the main form. Then on the subform he sees a datasheet
of all the existing countries belonging to the Axis. He is then free to add
or remove countries. EG, user selects 'Evil' from the Axis combobox, and
sees the countries Iran, Iraq, and North Korea on the datasheet. User then
is free to remove Iraq and add Syria, for example.

This is the way I link (or bind?) the forms. I write a query in which all
the records and axis are selected (eg SELECT * From inner join of both
tables) and I call this query 'qryCountriesInAxis'. Then, on the 'form'
object of both the main form and the subform, I set the 'Record Source'
property to 'qryCountriesInAxis'.

This seems to work for me. I can then use the 'List Master Fields' and
'List Child Fields' properties to link the two queries together.

My question is: am I going about this in an efficient manner?

Many thanks


Ilan
 
I want to have a mainform/subform as follows. User selects the Axes name
from a combo box on the main form. Then on the subform he sees a datasheet
of all the existing countries belonging to the Axis. He is then free to add
or remove countries. EG, user selects 'Evil' from the Axis combobox, and
sees the countries Iran, Iraq, and North Korea on the datasheet. User then
is free to remove Iraq and add Syria, for example.

This is the way I link (or bind?) the forms. I write a query in which all
the records and axis are selected (eg SELECT * From inner join of both
tables) and I call this query 'qryCountriesInAxis'. Then, on the 'form'
object of both the main form and the subform, I set the 'Record Source'
property to 'qryCountriesInAxis'.

This seems to work for me. I can then use the 'List Master Fields' and
'List Child Fields' properties to link the two queries together.

My question is: am I going about this in an efficient manner?

It's not necessary to use the inner join query on the subform - all
you really need is the Countries table. You can set the Master Link
Field property of the subform *to the name of the combo box* - this
isn't an option provided by the wizard, but you can type it in and it
works; and the foreign key field in tblCountries as the Child Link
Field.
 
Thanks. This is very useful. Somehow, when it comes to forms, I don't use
any grey cells, perhaps because I do not yet understand how forms work.
 
Back
Top