473,437 Members | 1,701 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,437 software developers and data experts.

Cascading Combo box.

Hello ,

I am trying to ve a cascading combo box in my form. I ve 2 Combo Boxes. Combo0 is based on the table TEST 1 and combo8 is based on table TEST 2.

TEST 1 has Company ID (Primary Key) , Company Name .

TEST2 has Address , Company ID

I ve linked the 2 tables through company ID.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo0_AfterUpdate()
  2.  
  3.  
  4. With Me![Combo8]
  5. If IsNull(Me!Combo0) Then
  6. .RowSource = " "
  7. Else
  8. .RowSource = "SELECT [Address] " & _
  9.              "FROM TblTEST 2 " & _
  10.              "WHERE [Company ID]=" & Me!Combo0
  11. End If
  12. Call .Requery
  13. End With
  14. End Sub
The above does nt work for me.

Could anyone please tell me where am i going wrong.

Thanks a lot.

Regards ,
Shreyans
Sep 2 '07 #1
8 1718
JConsulting
603 Expert 512MB
Hello ,

I am trying to ve a cascading combo box in my form. I ve 2 Combo Boxes. Combo0 is based on the table TEST 1 and combo8 is based on table TEST 2.

TEST 1 has Company ID (Primary Key) , Company Name .

TEST2 has Address , Company ID

I ve linked the 2 tables through company ID.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo0_AfterUpdate()
  2.  
  3.  
  4. With Me![Combo8]
  5. If IsNull(Me!Combo0) Then
  6. .RowSource = " "
  7. Else
  8. .RowSource = "SELECT [Address] " & _
  9.              "FROM TblTEST 2 " & _
  10.              "WHERE [Company ID]=" & Me!Combo0
  11. End If
  12. Call .Requery
  13. End With
  14. End Sub
The above does nt work for me.

Could anyone please tell me where am i going wrong.

Thanks a lot.

Regards ,
Shreyans

See this link...it's the same thing.

http://www.thescripts.com/forum/thread701767.html
Sep 3 '07 #2
See this link...it's the same thing.

http://www.thescripts.com/forum/thread701767.html
Hello,

I incorporated the changes as suggested by you at the above link.

Below is the code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo24_AfterUpdate()
  2. With Me![Combo30]
  3. If IsNull(Me!Combo24) Then
  4. .RowSource = ""
  5. Else
  6. .RowSource = "SELECT [Address]" & _
  7.              " FROM TblTEST 2" & _
  8.              " WHERE [Company ID]=" & Me!Combo24
  9. End If
  10.  
  11. End With
  12. End Sub
It still does not work. Just FOI i am using Access 2007.

Could u please help me out here .

Thanks
Sep 3 '07 #3
Stwange
126 Expert 100+
Hello,

I incorporated the changes as suggested by you at the above link.

Below is the code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo24_AfterUpdate()
  2. With Me![Combo30]
  3. If IsNull(Me!Combo24) Then
  4. .RowSource = ""
  5. Else
  6. .RowSource = "SELECT [Address]" & _
  7.              " FROM TblTEST 2" & _
  8.              " WHERE [Company ID]=" & Me!Combo24
  9. End If
  10.  
  11. End With
  12. End Sub
It still does not work. Just FOI i am using Access 2007.

Could u please help me out here .

Thanks
Although you didn't give the error message, I think the problem is your table name. Ideally, there shouldn't be spaces in the name, eg. tblTEST_2, but in this case, using square brackets should do the trick:
Expand|Select|Wrap|Line Numbers
  1. .RowSource = "SELECT [Address] FROM [TblTEST 2] WHERE [Company ID] =" & Me!Combo24 & ";"
  2.  
NOTE: If Company ID is not stored as a number (regardless of whether it is numeric or not), you need ' ' (or " " but these need escape characters) either side of the WHERE, so it would be
Expand|Select|Wrap|Line Numbers
  1.  [Company ID] = '" & Me!Combo24 & "';"
Sep 3 '07 #4
Although you didn't give the error message, I think the problem is your table name. Ideally, there shouldn't be spaces in the name, eg. tblTEST_2, but in this case, using square brackets should do the trick:
Expand|Select|Wrap|Line Numbers
  1. .RowSource = "SELECT [Address] FROM [TblTEST 2] WHERE [Company ID] =" & Me!Combo24 & ";"
  2.  
NOTE: If Company ID is not stored as a number (regardless of whether it is numeric or not), you need ' ' (or " " but these need escape characters) either side of the WHERE, so it would be
Expand|Select|Wrap|Line Numbers
  1.  [Company ID] = '" & Me!Combo24 & "';"
Hello ,

Thanks for the quick response.

I ve stored Company ID has number.

As regards the space in "TEST 2" ; i enclosed it with the square. However , i still didnt work . So i tried removing the space i.e TEST2.
But the error mesg that i get always is that

'SELECT [Address] FROM TblTEST2 WHERE [Company ID]=1' specified on this form does not exists.

Its my third day on this and still cant get this solved :-(
Sep 3 '07 #5
Stwange
126 Expert 100+
Hello ,

Thanks for the quick response.

I ve stored Company ID has number.

As regards the space in "TEST 2" ; i enclosed it with the square. However , i still didnt work . So i tried removing the space i.e TEST2.
But the error mesg that i get always is that

'SELECT [Address] FROM TblTEST2 WHERE [Company ID]=1' specified on this form does not exists.

Its my third day on this and still cant get this solved :-(
The table name needs to match the actual name of your table exactly.
Put a semi-colon at the end of the rowsource, and ensure that the RowSourceType of this combobox is set to Table/Query at design time.
Sep 3 '07 #6
The table name needs to match the actual name of your table exactly.
Put a semi-colon at the end of the rowsource, and ensure that the RowSourceType of this combobox is set to Table/Query at design time.
Yes , its exactly as what u ve said .
for combo 24
RowSource = SELECT [TEST1].[Company ID], [TEST1].[Company Name] FROM TEST1;

RowSourceType= Table/query.

Can i mail you my db .
Sep 3 '07 #7
--------------------
I ve mailed you at: [email removed]

Thanks
Sep 3 '07 #8
JConsulting
603 Expert 512MB
Yes , its exactly as what u ve said .
for combo 24
RowSource = SELECT [TEST1].[Company ID], [TEST1].[Company Name] FROM TEST1;

RowSourceType= Table/query.

Can i mail you my db .

Do you by chance have ' marks in some of your company names?

Example: O'Hara's Nightclub

??
J
Sep 3 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: cognoscento | last post by:
I'm currently putting together a database for my work (not an expert by any stretch, so muddling through as best as I can... you know the story...) and I could use some advice and hand-holding ...
9
by: Edwinah63 | last post by:
Hi everyone, Please let there be someone out there who can help. I have two BOUND combo boxes on a continuous form, the second being dependent on the first. I have no problem getting the...
4
Rabbit
by: Rabbit | last post by:
Cascading Combo/List Boxes This tutorial is to guide you in the creation of Cascading combo/list boxes. That is when you have multiple combo/list boxes where the selection of an option in one...
3
by: buddyr | last post by:
Hello, Yesterday I recieved help with two cascading combo boxes on an access form. I went the link http://www.fontstuff.com/access/acctut10.htm And basically used their first example. Now I...
7
kcdoell
by: kcdoell | last post by:
I have three tables: One for the Division location: tblDivision DivisionID = Autonumber DivisionName = Text One for the Working Region: tblWrkRegion
4
klarae99
by: klarae99 | last post by:
Hello, I am working on an Access 2003 Database. The tables that pertain to this issue are tblOrg, tblState, tblCity, and tblZip. I have posted the table structure with only the pertinant fields...
3
kcdoell
by: kcdoell | last post by:
I have 5 cascading combo boxes on a form. Below is a sample of my vb in the first combo box: Private Sub CboDivision_AfterUpdate() 'When the Division is selected, the appropriate Segment...
7
by: Toireasa | last post by:
Hi, Newbie Access developer here, and my first post on this forum, so I might not get everything right - thanks in advance for your help and your patience! I'm using Access 2007, in XP. I'm...
8
by: 20028431 | last post by:
This is driving me mad! I have been trying for 3 days now to work out how to do this with no success. I have tables for Customer, Bookings, Entertainment, Act, Agent, and several others. I...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.