473,473 Members | 1,906 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Another Multiple Combo box Question

25 New Member
Hi Everyone,

I have a form set as a dialog box with 2 Combo boxes (Combo0 & Combo4) and 2 text boxes (text8 & text10).

The form's record source is set to a table named Customers.

Combo0's row source is set to a query conatining the Customer Name Field in Customers

Combo4 lists only the citys of whaterver customer is picked from combo0.

Text10's control source is the state field in customers
Text8's control source is a unique ID field in customers.

When you choose a customer name in combo0 and then a city in combo4 text10 & text8 become visible and dsplay the related state and unique ID for that location.

My problem is that if there is more than one customer in the same city my code only returns the state(Text10) and unquie ID(Text8) for the first match that it comes to in the table.

Here's the code of combo0 AfterUpdate:
Expand|Select|Wrap|Line Numbers
  1. Dim wclause
  2.  
  3.     [Combo4].Visible = True
  4.  
  5.     wclause = "SELECT Customers.CITY FROM Customers WHERE customers.[company name]=[combo0];"
  6.     [Combo4] = " "
  7.     [Combo4].RowSource = wclause
Here's the code from Combo4 AfterUpdate:
Expand|Select|Wrap|Line Numbers
  1. Dim rs As Object
  2.  
  3.     Set rs = Me.Recordset.Clone
  4.     rs.FindFirst "[CITY] = '" & Me![Combo4] & "'"
  5.     If Not rs.EOF Then Me.Bookmark = rs.Bookmark
  6.  
  7.     [Text10].Visible = True
  8.     [Text8].Visible = True

I'm sure the problem is in the code of combo4 but I don't know how to fix it. Any help would be greatly appreciated and Thanks in advance!
Jun 21 '07 #1
16 2605
MMcCarthy
14,534 Recognized Expert Moderator MVP
Have a look at this tutorial.

Cascading combo/list boxes
Jun 22 '07 #2
teric2
25 New Member
Yea, I've looked at this and my Combo boxes work fine. it's the results I want in the text boxes after picking from the combo boxes that I'm having a problem with.

Thanks!
Jun 22 '07 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
Yea, I've looked at this and my Combo boxes work fine. it's the results I want in the text boxes after picking from the combo boxes that I'm having a problem with.

Thanks!
The combo0 After Update does not follow the rules of this tutorial. Have another look at it.
Jun 22 '07 #4
teric2
25 New Member
I don't think that code will work for me but I could be wrong. Here is the structure of my customer table

RXDC no <-- a unique id number or text string(field is set as text)
customer name
Address1
Address2
City
State
Zip

Each customer may have many locations in different citys each with it's own Unique ID(RXDC no) and record in the table

Combo0's row source is set to a Query that contains the customer name field sorted and set to show unique values so the same customer name doesn't appear over and over again in the combo box.

The code in the tutorial is set to return the unique ID number for the customer name selected. Which, in my case, the name for several locations will only display once.
It's the combination of Combo0(Customer Name) and Combo4(City) that will result in the unique ID(RXDC no) and record I'm looking for to display in my two text boxes.

What I want is to choose a customer name and then a city for that customer and then have the state and unquie ID for that combination display in the text boxes
Jun 22 '07 #5
MMcCarthy
14,534 Recognized Expert Moderator MVP
Combo0
Row Source = SELECT DISTINCT [customer name] FROM Customers

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo0_AfterUpdate()
  2. Dim strRowSource As String
  3.  
  4.     Me!Combo4.Visible = True
  5.     strRowSource = "SELECT City FROM Customers WHERE [company name]='" & Me!Combo0 & "'"
  6.     Me!Combo4.RowSource = strRowSource
  7.     Me!Combo4.Requery
  8.  
  9. End Sub
  10.  
Assuming you have a textbox to hold the value of the RXDC no called txtRXDC

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo4_AfterUpdate()
  2.  
  3.     Me!txtRXDC = DLookup("[RXDC no]", "Customers", "[customer name]='" & Me!Combo0 & "' AND [City]='"  & Me!Combo4 & "'"
  4.  
  5. End Sub
  6.  
Jun 22 '07 #6
teric2
25 New Member
This works great mmccarthy. I knew you'd come through for me. You've helped me before.

One more question.
Some of my customer names have an apostrophe in them to show possesion. When I select one of these I get a "Syntax error" in the code for combo4.

Anyway to fix it other than to remove the apostrophes?
Jun 22 '07 #7
MMcCarthy
14,534 Recognized Expert Moderator MVP
This works great mmccarthy. I knew you'd come through for me. You've helped me before.

One more question.
Some of my customer names have an apostrophe in them to show possesion. When I select one of these I get a "Syntax error" in the code for combo4.

Anyway to fix it other than to remove the apostrophes?
Try this

"SELECT City FROM Customers WHERE [company name]=" & """ & Me!Combo0 & """
Jun 22 '07 #8
teric2
25 New Member
Hmm that results in combo4 being empty.
Jun 22 '07 #9
MMcCarthy
14,534 Recognized Expert Moderator MVP
Hmm that results in combo4 being empty.
I know there's a way of dealing with this, I just can't remember it at the moment.

I'll get back to you
Jun 22 '07 #10
MMcCarthy
14,534 Recognized Expert Moderator MVP
Try this ...

"SELECT City FROM Customers WHERE [company name]=""" & Me!Combo0 & """"

If that doesn't work you may need to use this function.

http://www.thescripts.com/forum/thread641552.html
Jun 22 '07 #11
teric2
25 New Member
That worked except now I get a syntax error (Missing Operator) for this code in the AfterUpdate procedure of the second combo box(Combo4):

Expand|Select|Wrap|Line Numbers
  1. Me!Text8 = DLookup("[RXDC no]", "Customers", "[company name]='" & Me!Combo0 & "' AND [City]='" & Me!Combo4 & "'")
Sorry it took so long to get back to this and thanks again for helping.
Jun 26 '07 #12
MMcCarthy
14,534 Recognized Expert Moderator MVP
Try this

Expand|Select|Wrap|Line Numbers
  1. Me!Text8 = DLookup("[RXDC no]", "Customers", "[company name]=""" & Me!Combo0 & """" & " AND [City]='" & Me!Combo4 & "'")
  2.  
Jun 26 '07 #13
teric2
25 New Member
Afraid not. Still get the same error. Guess I'll have to try the function that you pointed me to unless you have any more ideas.
Jun 27 '07 #14
MMcCarthy
14,534 Recognized Expert Moderator MVP
Afraid not. Still get the same error. Guess I'll have to try the function that you pointed me to unless you have any more ideas.
I'm not sure whats going on but I've tested the code

Me!Text8 = DLookup("[RXDC no]", "Customers", "[company name]=""" & Me!Combo0 & """" & " AND [City]='" & Me!Combo4 & "'")

And it works fine
Jun 27 '07 #15
teric2
25 New Member
My mistake. I should have looked closer. I copied and pasted your code but, in the mean time, I somehow lost the original SQL from Combo0.

Works great now!

Thanks tons for your time and patience. This is a great place to learn.
Jun 27 '07 #16
MMcCarthy
14,534 Recognized Expert Moderator MVP
My mistake. I should have looked closer. I copied and pasted your code but, in the mean time, I somehow lost the original SQL from Combo0.

Works great now!

Thanks tons for your time and patience. This is a great place to learn.
Not a problem. Glad you got it working.
Jun 27 '07 #17

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

Similar topics

3
by: vgrssrtrs | last post by:
<html> <head> <script language="JavaScript"> <!-- /* *** Multiple dynamic combo boxes *** by Mirko Elviro, 9 Mar 2005 *** ***Please do not remove this comment
2
by: news.hp.com | last post by:
I have situation where I need to copy multiple records (only certain fields) from a Rules table to an Events table based on a selection identified in a combo box. When the selection is made in a...
1
by: meganrobertson22 | last post by:
hi everybody- what is the best way to add data from one form to another? i have 2 tables: person and contract. here are some of the fields. table: person personid (autonumber and primary...
10
by: lorirobn | last post by:
Hi, I have a form with several combo boxes, continuous form format, with record source a query off an Item Table. The fields are Category, Subcategory, and Color. I am displaying descriptions,...
3
by: hmiller | last post by:
Hey everyone, I am having a hell of a time trying to set this menu system up. Here's what I'm trying to do. Combo Box One; is populated by names under properties "row source" "Phase 1"...
0
by: zhuang | last post by:
Hi, Adding combobox to datagrid has been posted many times. I have a datagrid which has multiple combobox columns and normal textbox columns. But how could I change other combo box values at...
1
by: Shawn Yates | last post by:
It has been a while since I have done anything on MS Access and I seem to be a bit rusty. I hope someone could help me solve my issue. I have a form that has multiple combo boxes on it. Each box...
4
by: tbayse | last post by:
Hello, I have a question about making multiple selection queries in Access. I am running windows XP and Access 2003. Up until this point I had a form where a user would make single selections from...
2
by: MicaK | last post by:
Good Morning, I am new to this forum, and extremely new to VBA, so there may be a very simple explanation to this. I also apologize if I am giving you and excessive amount of detail. I have a...
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,...
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.