473,395 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

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
5 2399
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Gamze | last post by:
Hi, How can i get values from datagrid to combobox and should select the same name as in datagrid row on the combobox control In my vb.net windows application ,i have combobox which is...
10
by: DettCom | last post by:
Hello, I would like to be able to display or hide fields based on whether a specific Yes/No radio button is selected. This is in conjunction with a posting a just made here in the same group...
0
by: Elvis V. | last post by:
Good morning, I have a table that contains three fields that I would like to relate one to another, in other words, for example, when I go to the form and I click on the drop down box for...
3
by: google | last post by:
This is something I've done plenty of times in '97, but I can't seem to get it to work correctly in Access 2003. Say, for example, I have a form with an unbound combobox, the data source is a...
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
8
by: Lysander | last post by:
Hi, I am using Access 2003 I have seen some threads on how to select multiple values from a list box, but how do I display the selected options back again (Last time I used Access in anger, you...
2
by: giandeo | last post by:
Hello all, It's almost a couple of weeks since i am struggling to get this code work. Unfortunately, i am stuck. There seems to be no hope... Please Help....... I am working with an asp page...
1
by: fsalvador | last post by:
Hi, I need help with this. I am trying to figure it out but I can't. I have 2 pages. I would like to display in the second page the content of one class and hide the content of the other...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.