Linking combo box to subforms

C

Clydy

Page 1 of main form/with tabs lists information such as
address, city, etc. (Primary key is LocID). I have linked
a subform to it that has a drop down box so I can choose
what type of building is located at this address (Primary
key BuildingID). I have linked another subform to the
Building subform with a dropdown box (RoomID)that I can
choose what type of rooms are in the building (a.e.
livingroom, den, etc.)(Primary key BuildingRoomID).
On Page 2 of the form I want to have a dropdown box that
will list the rooms I have selected in the previous
subform. I have tried several different ways. I keep
getting a combo box that lists all rooms to several
locations. Can someone help
 
S

Steve Schapel

Clydy,

In the table where the rooms are listed, you have a BuildingRoomID
primary key field, and also, I presume, a BuildingID field as a foreign
key field to the Buildings table, right? Ok, your the rowsource of your
combobox on the second page needs to be a query which refers to the
BuildingID on your first subform. Without knowing more details of your
actual tables, I can't be specific, but the SQL of the query for the
combobox rowsource will be something like...
SELECT RoomID FROM BuildingRooms WHERE BuildingID =
[Forms]![MainForm]![BuildingSubform]![BuildingID]
 
J

James Goodman

You will need to set the rowsource of the combo box to something along the
lines of:

SELECT ColumNames FROM SourceTable WHERE BuildID = Forms!FormName!CboName

I am guessing ColumnNames will be RoomID, RoomDesc
I am guessing SourceTable will be something like tblRooms & contain BuildID,
RoomTypeID




--
Cheers,


James Goodman MCSE, MCDBA
http://www.angelfire.com/sports/f1pictures
 

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