By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,572 Members | 2,949 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,572 IT Pros & Developers. It's quick & easy.

How to display only values related only to the value selected on previous field

P: n/a
Good morning, I have a table with three fields, Buildings, Floors and
Rooms.
This is what I would like to do; in my form when I select Building1 in
my drop down box for Buildings, when I go to the next drop down field
which is Floors, all I would like to see is just the floors that
belong to Building1 only and then once I have selected a value for
Floors, when I go to the next drop down field which is Rooms, all I
want to see are the rooms that belong only to the previous selected
Floor value, which belongs to that specific selected Building only.
Right now, when I go to my form and go to these fields what I get is
everything that there is in the table. I get to see all the Floors and
Rooms values for every building out there regardless of the value I
have selected for Buildings. How can I prevent this from happening?
How can I tight down the Rooms values to the Floors and the Floors
values to the selected Buildings values?
So far this is what I have done:

Private Sub Floors_GotFocus(Floors)
' Passing on the value of Buildings in order to display Floors
' only pertaining to selected Building.

Dim stLinkCriteria As String

strSQL = "Select [Floors] from tblLocations where [Building]=" &
Me![Building]

End Sub

Thank you.
Nov 12 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hello
Create 3 combo boxes on your form (Form1): cmbBuildings, cmbFloors,
cmbRooms. Base these combo boxes on queries:
qryBuildings: SELECT DISTINCT tblLocations.Buildings FROM
tblLocations;

QryFloors: SELECT tblLocations.Floors FROM tblLocations
WHERE tblLocations.Buildings=[Forms]![Form1]![cmbBuildings];

QryRooms: SELECT tblLocations.Rooms, tblLocations.Buildings,
tblLocations.Floors
FROM tblLocations WHERE
tblLocations.Buildings=[Forms]![Form1]![cmbBuildings] AND
tblLocations.Floors=[Forms]![Form1]![cmbFloors];

In OnGotFocus event of cmbFloors place:
Private Sub cmbFloors_GotFocus()
cmbFloors.Requery
End Sub

In OnGotFocus event of cmbRooms place:
Private Sub cmbRooms_GotFocus()
cmbRooms.Requery
End Sub

This will do the trick.
Galina

el*****@miamidade.gov (Elvis V.) wrote in message news:<92**************************@posting.google. com>...
Good morning, I have a table with three fields, Buildings, Floors and
Rooms.
This is what I would like to do; in my form when I select Building1 in
my drop down box for Buildings, when I go to the next drop down field
which is Floors, all I would like to see is just the floors that
belong to Building1 only and then once I have selected a value for
Floors, when I go to the next drop down field which is Rooms, all I
want to see are the rooms that belong only to the previous selected
Floor value, which belongs to that specific selected Building only.
Right now, when I go to my form and go to these fields what I get is
everything that there is in the table. I get to see all the Floors and
Rooms values for every building out there regardless of the value I
have selected for Buildings. How can I prevent this from happening?
How can I tight down the Rooms values to the Floors and the Floors
values to the selected Buildings values?
So far this is what I have done:

Private Sub Floors_GotFocus(Floors)
' Passing on the value of Buildings in order to display Floors
' only pertaining to selected Building.

Dim stLinkCriteria As String

strSQL = "Select [Floors] from tblLocations where [Building]=" &
Me![Building]

End Sub

Thank you.

Nov 12 '05 #2

P: n/a
Galina,
thank you for your reply.
I went ahead and did exactly as you told me. When I go to the form, the
cmbBuilding works fine, it gives me all the values in that field. Once I
select a value in Building and go to the cmbFloors, I just get a blank
field, no values displayed. What am I missing?
Thank you.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3

P: n/a
Elvis
I have no possibility to know, what you are missing without looking at
your form. A spelling mistake? Have you swap Form1 in my code by the
name of your form? I can send you the form, which I have made when
preparing my answer, if you wish.
Galina
Elvis Vazquez <el*****@miamidade.gov> wrote in message news:<3f***********************@news.frii.net>...
Galina,
thank you for your reply.
I went ahead and did exactly as you told me. When I go to the form, the
cmbBuilding works fine, it gives me all the values in that field. Once I
select a value in Building and go to the cmbFloors, I just get a blank
field, no values displayed. What am I missing?
Thank you.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #4

P: n/a
Galina,
I got it. It was the way I had the cells formatted. I had it looking
into the second column instead of the first one, therefore it was
blank; there was nothing to be displayed on the second column.
Thank you very much and have a great weekend.
Elvis V

Elvis Vazquez <el*****@miamidade.gov> wrote in message news:<3f***********************@news.frii.net>...
Galina,
thank you for your reply.
I went ahead and did exactly as you told me. When I go to the form, the
cmbBuilding works fine, it gives me all the values in that field. Once I
select a value in Building and go to the cmbFloors, I just get a blank
field, no values displayed. What am I missing?
Thank you.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #5

P: n/a
ga*********@cityofbristol.ac.uk (Galina) wrote in message news:<cc**************************@posting.google. com>...
Elvis
I have no possibility to know, what you are missing without looking at
your form. A spelling mistake? Have you swap Form1 in my code by the
name of your form? I can send you the form, which I have made when
preparing my answer, if you wish.
Galina
Elvis Vazquez <el*****@miamidade.gov> wrote in message news:<3f***********************@news.frii.net>...
Galina,
thank you for your reply.
I went ahead and did exactly as you told me. When I go to the form, the
cmbBuilding works fine, it gives me all the values in that field. Once I
select a value in Building and go to the cmbFloors, I just get a blank
field, no values displayed. What am I missing?
Thank you.

Galina, thank you for your help. The problem was the way I had the drop
down boxes formatted. I fixed them and they are working like a charm.
Have a great day and thanks for your help.
Elvis V.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.