Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / November 2006

Tip: Looking for answers? Try searching our database.

Combo box alternate values

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AshGrant - 23 Nov 2006 09:13 GMT
Hi, guys - Rather simple but baffling question I have here...

I have a booking form for an accomodation database. I want the user to be able
to select the bed number they wish to book a customer into, bearing in mind,
rooms can contain any number of beds between 1 and 8.

For example,
John Smith wishes to book into Room 119, this room has 4 beds in it, the
user wishes to book him into bed No.2
Gary Smith wishes to book into Room 119 also, but this time into Bed No.3

I know I need a combo box for this but how can I deal with the RowSource?
i.e sometimes it will display a list of numbers 1 - 3 and other times it will
display a list of numbers 1 - 8, depending on how many beds are in the
selected room.
Any ideas how I can achieve this? Many thanks!

Ash.
Rick Brandt - 23 Nov 2006 12:50 GMT
> Hi, guys - Rather simple but baffling question I have here...
>
[quoted text clipped - 12 lines]
> selected room.
> Any ideas how I can achieve this? Many thanks!

You need a table that holds the data for what beds are in each room (assume you
already have that).  Then the fist ComboBox has a RowSource that simply lists
all the rooms....

SELECT RoomNumber FROM Rooms

The second ComboBox will list bed numbers and will have a criteria referencing
back to the first ComboBox...

SELECT BedNumber
FROM Rooms
WHERE RoomNumber = Forms!FormName!RoomNumber

You will need to use code in the AfterUpdate event of the RoomNumber ComboBox
that requeries the BedNumber ComboBox...

Me!ComboBox.Requery

Signature

Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com

Douglas J. Steele - 23 Nov 2006 14:04 GMT
>> Hi, guys - Rather simple but baffling question I have here...
>>
[quoted text clipped - 33 lines]
>
> Me!ComboBox.Requery

Actually, the SQL for the RowSource will probably need to be a little more
complicated than that, to ensure that the second time they look at Room 119,
it only lists beds 1, 2  and 3 (since John Smith already has bed 4)

Ash: If you need help with the SQL, post the details of the tables in your
application.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.