I am trying to make a combo box return a value based on a combo box selection. I have tried a number of the codes posted here and am still having problems. I think it is because I am trying to return a value from a table that only links with the form through an intermediate table. I am hoping to avoid a subform for this one box if at all possible, because of space limitations. Any guidance would be greatly appreciated!
I have a form called frmBldgs based on a table called tblBldgs with the following fields:
Field1: BldgID – autonumber primary key
Field2: BldgNm – name of building
Field3: Addr1IDFK – foreign key that links to a table called tblAddr1
Field4: DistrictIDFK – foreign key that links to a table called tblDistricts
etc….
The table called tblDistricts has the following fields:
Field1: DistrictID – autonumber primary key
Field2: DistrictNm – name of sanitation district
Field3: SanBoroIDFK – foreign key that links to a table called tblSanBoros
(Each SanBoro has a number of districts nested beneath it.)
The table called tblSanBoros has the following fields:
Field1: SanBoroID – autonumber primary key
Field2: SanBoroNm
Field3: BoroIDFK – foreign key that links to a table called tblBoroughs
(Each Borough has one or two SanBoros nested beneath it.)
I also have the following simple query, called qrySanDistBoro:
SELECT tblBldgs.DistrictIDFK, tblSanBoros.SanBoroID, tblDistricts.DistrictNm, tblSanBoros.SanBoroNm
FROM tblSanBoros INNER JOIN (tblDistricts INNER JOIN tblBldgs ON tblDistricts.DistrictID = tblBldgs.DistrictIDFK) ON tblSanBoros.SanBoroID = tblDistricts.SanBoroIDFK;
The first combo box I am working with in frmBldgs is called cboSanDistrict.
Its ControlSource is DistrictIDFK.
I made the Row Source the following so that it returns the DistrictNm in the form from tblDistricts:
Expand|Select|Wrap|Line Numbers
- SELECT tblDistricts.DistrictID, tblDistricts.DistrictNm
- FROM tblDistricts
- ORDER BY tblDistricts.DistrictID;
The Control Source for cboSanBoro is DistrictIDFK.
For the Row Source, I have tried using the following query
SELECT qrySanDistBoro.SanBoroNm
FROM qrySanDistBoro;
This did not work. The combo box just returns the DistrictIDFK associated with the DistrictNm in cboSanDistrict.
I’m guessing the simple query was too simple because tblSanBoros is not directly linkable to tblBldgs except through tblDistricts. Maybe I need to change the control source?? (but to what?)
Thanks in advance, any help would be greatly appreciated!
Bridget