Greetings all. I know that cascading lists are a common problem and in truth I my initial post here was to request help with my own, but then I figured out the right code. That being said, I have a new challenge which I'm not sure how to go about. Here is my situation:
I presently have 2 combo boxes (cboBuilding, cboRoom) and which are properly cascading. That's great, but now I want to be able to pull the RoomDescription for the room that was selected (basically autopopulate a field on the form and have it be uneditable if possible). I am uncertain how to go about doing this.
Here are the basic layouts of my two tables and what I have done:
tblBuilding
[BuildingID] - Primary Key (Autonumber) for Building Table
[BuildingName] - Name of Building
tblRoom
[RoomPK] - Primary Key (Autonumber) for Room Table
[RoomNumber] - Room Number for specific room
[RoomDescription] - Description of the room
[BuildingID] - FK to Building Table; identifies which building specific room is in
Private Sub Building_AfterU pdate()
'When the Building is selected, the appropriate Room list will
'display in the drop down list of CboRoom
1. With Me![Room]
2. If IsNull(Me!Build ing) Then
3. .RowSource = ""
4. Else
5. .RowSource = "SELECT [RoomNumber] " & _
6. "FROM tblRoom " & _
7. "WHERE [BuildingID]=" & Me!Building
8.
9. End If
10. Call .Requery
11. End With
12. End Sub
** My apologies for how the code looks. I write it spaced out nice and neat but when I post it doesn't include my spaces, any help with how to fix that is appreciated for future posts **
So the query above works fine to autopopulate my Room list, however I am not certain how to go about getting the Room Description onto the form. For one, the source for the form is a single table which has nothing to do (specifically) for the Room, which I used code to work around previously (above). I've managed to get a "Room Description" field onto the form, though it is complaining about the control source (rightfully so) as the primary data source for this form is exclusive of the Room Table data.
I am certain all I need is to create a query which will pull in the room description for the field based on the previous two choices by the user (i.e. the Building and specific Room selected). I know what I want to accomplish, I am just not certain as to the how to make it happen. Do I build another event? If so, which one? After Update again?
Any help is greatly appreciated! If you need more information, please let me know!
I presently have 2 combo boxes (cboBuilding, cboRoom) and which are properly cascading. That's great, but now I want to be able to pull the RoomDescription for the room that was selected (basically autopopulate a field on the form and have it be uneditable if possible). I am uncertain how to go about doing this.
Here are the basic layouts of my two tables and what I have done:
tblBuilding
[BuildingID] - Primary Key (Autonumber) for Building Table
[BuildingName] - Name of Building
tblRoom
[RoomPK] - Primary Key (Autonumber) for Room Table
[RoomNumber] - Room Number for specific room
[RoomDescription] - Description of the room
[BuildingID] - FK to Building Table; identifies which building specific room is in
Private Sub Building_AfterU pdate()
'When the Building is selected, the appropriate Room list will
'display in the drop down list of CboRoom
1. With Me![Room]
2. If IsNull(Me!Build ing) Then
3. .RowSource = ""
4. Else
5. .RowSource = "SELECT [RoomNumber] " & _
6. "FROM tblRoom " & _
7. "WHERE [BuildingID]=" & Me!Building
8.
9. End If
10. Call .Requery
11. End With
12. End Sub
** My apologies for how the code looks. I write it spaced out nice and neat but when I post it doesn't include my spaces, any help with how to fix that is appreciated for future posts **
So the query above works fine to autopopulate my Room list, however I am not certain how to go about getting the Room Description onto the form. For one, the source for the form is a single table which has nothing to do (specifically) for the Room, which I used code to work around previously (above). I've managed to get a "Room Description" field onto the form, though it is complaining about the control source (rightfully so) as the primary data source for this form is exclusive of the Room Table data.
I am certain all I need is to create a query which will pull in the room description for the field based on the previous two choices by the user (i.e. the Building and specific Room selected). I know what I want to accomplish, I am just not certain as to the how to make it happen. Do I build another event? If so, which one? After Update again?
Any help is greatly appreciated! If you need more information, please let me know!
Comment