473,757 Members | 10,708 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Combo Box dependent on text box

25 New Member
Hello ,

I ve a form which is based on a table viz SalesOrder.

1 of the field which Sales Order has is : Client.

I ve 2 more tables, (a) Client which has 1 field viz ClientName , (b) ClientDetails which has 2 fields ClientName and Address. The tables are linked ( the link being client name) . This ofcourse means , a particular client could ve multiple addresses.

Every time a sales order is excuted , the equipments need to be supplied to a particular location as requested by the client.

Thus i ve created a combo box on the form through which i would select the address.

Now what i want is i should get to see only those locations as are pertaining to the relevant Client . The problem here is , it is not 1 combo box dependent on another combo box. The Combo box is dependent on the text box "Client" .

I am using the following After_Update code

Expand|Select|Wrap|Line Numbers
  1. Private Sub Client_AfterUpdate()
  2.  
  3.  
  4.  
  5.  
  6. With Me![Combo9]
  7. If IsNull(Me!Client) Then
  8. .RowSource = ""
  9. Else
  10. .RowSource = "SELECT [ClientAddress]" & _
  11.              " FROM [ClientDetail]" & _
  12.              " WHERE [ClientName]=" & Me!Client
  13. End If
  14.  
  15. End With
  16.  
  17.  
  18. End Sub

It doesn't work. Could someone pls guide me here.

Thanks a lot.
Sep 16 '07 #1
4 3479
puppydogbuddy
1,923 Recognized Expert Top Contributor
Hello ,

I ve a form which is based on a table viz SalesOrder.

1 of the field which Sales Order has is : Client.

I ve 2 more tables, (a) Client which has 1 field viz ClientName , (b) ClientDetails which has 2 fields ClientName and Address. The tables are linked ( the link being client name) . This ofcourse means , a particular client could ve multiple addresses.

Every time a sales order is excuted , the equipments need to be supplied to a particular location as requested by the client.

Thus i ve created a combo box on the form through which i would select the address.

Now what i want is i should get to see only those locations as are pertaining to the relevant Client . The problem here is , it is not 1 combo box dependent on another combo box. The Combo box is dependent on the text box "Client" .

I am using the following After_Update code

Expand|Select|Wrap|Line Numbers
  1. Private Sub Client_AfterUpdate()
  2.  
  3. With Me![Combo9]
  4. If IsNull(Me!Client) Then
  5. .RowSource = ""
  6. Else
  7. .RowSource = "SELECT [ClientAddress]" & _
  8.              " FROM [ClientDetail]" & _
  9.              " WHERE [ClientName]=" & Me!Client
  10. End If
  11.  
  12. End With
  13.  
  14.  
  15. End Sub

It doesn't work. Could someone pls guide me here.

Thanks a lot.
Your problem is most likely due to ambiguous references when you are referring to different controls. Also, you are not following standard prefixes for Access Objects.

object......... ............... .......prefix
_______________ _____________
table ............... ............... ....tbl
field.......... ............... ...........fld
form ............... ............... .....frm
textbox........ ............... ........txt
combobox....... ............... .....cbo

I've used the standard prefixes+names in place your names. If I have interpreted incorrectly, it is because I misinterpreted an ambiguous name.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboClient_AfterUpdate()
  2.  
  3. With Me![cboClient]
  4. If IsNull(Me!txtClient) Then
  5. .RowSource = ""
  6. Else
  7. .RowSource = "SELECT [ClientAddress]" & _
  8.              " FROM [ClientDetail]" & _
  9.              " WHERE [ClientName]=" & Me!txtClient
  10. End If
  11.  
  12. End With
  13.  
  14.  
  15. End Sub
Sep 16 '07 #2
shreyansghia
25 New Member
Your problem is most likely due to ambiguous references when you are referring to different controls. Also, you are not following standard prefixes for Access Objects.

object......... ............... .......prefix
_______________ _____________
table ............... ............... ....tbl
field.......... ............... ...........fld
form ............... ............... .....frm
textbox........ ............... ........txt
combobox....... ............... .....cbo

I've used the standard prefixes+names in place your names. If I have interpreted incorrectly, it is because I misinterpreted an ambiguous name.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboClient_AfterUpdate()
  2.  
  3. With Me![cboClient]
  4. If IsNull(Me!txtClient) Then
  5. .RowSource = ""
  6. Else
  7. .RowSource = "SELECT [ClientAddress]" & _
  8.              " FROM [ClientDetail]" & _
  9.              " WHERE [ClientName]=" & Me!txtClient
  10. End If
  11.  
  12. End With
  13.  
  14.  
  15. End Sub

Hi ,

I tried with ur suggestions. But it doesnt work. FOI i am using MS Access 2007.
Also as per ur code, my texd box and combo box are both named Client. However my combo is combo9 and the text box is Client.

Combo9 is dependent on textbox client.

Is there anything else u can suggest
Sep 17 '07 #3
FishVal
2,653 Recognized Expert Specialist
Hi, there.

I guess [ClientDetail].[ClientName] is text type table field.
SQL syntax requires string constants to be enclosed in single quotes.
So try the following modification for RowSource string.
Expand|Select|Wrap|Line Numbers
  1. .RowSource = "SELECT [ClientAddress]" & _
  2.              " FROM [ClientDetail]" & _
  3.              " WHERE [ClientName]='" & Me!txtClient & "';"
  4.  
Sep 17 '07 #4
shreyansghia
25 New Member
Hi, there.

I guess [ClientDetail].[ClientName] is text type table field.
SQL syntax requires string constants to be enclosed in single quotes.
So try the following modification for RowSource string.
Expand|Select|Wrap|Line Numbers
  1. .RowSource = "SELECT [ClientAddress]" & _
  2.              " FROM [ClientDetail]" & _
  3.              " WHERE [ClientName]='" & Me!txtClient & "';"
  4.  
Hi ,

Well, it still didnt work . However , i used the following for the RowSource of my combobox

Expand|Select|Wrap|Line Numbers
  1. SELECT [ClientDetail].[ClientAddress] FROM ClientDetail WHERE [ClientDetail].[ClientName]=Form!Client; 
It works now , but not in a very efficient manner :-).

Thanks anyways for the help
Sep 20 '07 #5

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

Similar topics

10
9574
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, not ID's, so I have to convert the ID's from various lookup tables. The combo boxes work fine except for subcategory, which is dependent on category. Depending on category, the drop-down box for subcategory will display different items. (for...
9
6761
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 second combo to change depending on what values the user selects in the first box, it's just that every time the user changes the first combobox, the second combobox FOR EVERY RECORD goes blank.
2
3069
by: visionstate | last post by:
Hi there, I am working on a form that uses 3 text boxes and 3 combo boxes. When any data is entered into any of these, I click a command button and this requeries a sub query in the form and displays data dependent on what has been typed in. After having trouble with populating my second combo box (I eventually populated it by putting the fields for both combo boxes in 1 separate query) I am now having problems with the 3rd one and am...
4
2511
by: Miguel | last post by:
I have an order entry database with two forms. One is for new orders the other is to update orders. The forms are identical except that one is strictly order entry. On both forms are three sets of sychronized combo boxes. When entering test data everything worked perfectly. I recently migrated 5,000+ records from an Excel file to the database. The migration was successful and all records were copied over. When I checked the underlying...
4
3032
by: Swinky | last post by:
I am trying to make a combo box dependent on a text box. I cannot get the combo box to pull the related data from the text box. I have been all over this user group & have tried several versions of code to no avail. I would like to display all contact names (in the combo box) related to the customer number in the text box. Here's what I have:
8
2484
by: Cerian | last post by:
Hi there, I'm having trouble getting my 3rd dependent combo box to work in Access 2003. I have three dependent boxes named cbogroup, cbosection and cbofunction. Each one is dependent on the selection made in the previous box. All of these appear on one form called 'records subform'. The information for each box is taken from a different table. The first from 'functional group' which has only 2 fields: 'group' and 'group code'. The...
4
2189
by: deanndra | last post by:
First, I want to say thank you to Scott and the others who replied to my first post here. I had to put that database on hold for the moment when I was tasked with a new one. I am building another database from scratch. This one is for job announcements. I've built only 2 tables (I know this is a no-no, but it was demanded by those wanting this database so I've complied). The field name properties and data types in both tables are virtually...
2
4617
by: SHAWTY721 | last post by:
I have a form that contains two combo boxes that are related to each other. I need to find a way to populate my text box based on the criteria of the two combo boxes so the appropriate number appears in the text box.
1
1929
by: avigiano | last post by:
Good morning. I have a contacts database that tracks the regular things like phone numbers, address etc. User searches for contacts through a combo box that lists entires by last name. I've successfully added a dependent combo box that shows all of the first names for the entries of a given last name. For example, there might be 6 entries in the database with the last name "Brown" but only one entry "Sherwinas". Is it possible for...
0
9298
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10072
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9737
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8737
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7286
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5172
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3829
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 we have to send another system
3
3399
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.