473,563 Members | 2,662 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

making a combo box display a value from its list via code?

54 New Member
Hi

I have a form frmAdd_Equipmen t. It has a number of combo boxes on it, cboModel, cboSupplier, cboManufacturer , cboEquipment_Ty pe etc.

Bcause therer is no existing data to go off I put an ADD NEW cmdButton next to each of the ComboBoxes so if the item does not exist then the user can add a new Model, Supplier etc.

The various ComboBoxes all load from Queries when the Form Loads.

What I'd like to do, is to make it so that should the user click on cboModel, code behind the After Update event would somehow shuffle the data around in the other comboboxes..lik e Supplier, Manufacturer etc to make those ComboBoxes show the relevant data to the Model they originally selected with the cboModel. Then all the user would have to do is select the Department enter in the new Serial Number and Equipment number and click Save instead of having to trawl through and update each and every combo.

I wrote an strSQL string that creates a recordset based upon the Model selected and that works fine, but I cannot get the Columns of the combo boxes to change or update with values from the Recordset. (I guess because they have already been preloaded from the the initial queries during the Form Load event.

I guess I could place a text box next to each combobox, that would load if the user selected an already existing Model, but it would make an already busy form look really cluttered.

Thanks for any assistance
Mike
Dec 14 '08 #1
8 1645
nico5038
3,080 Recognized Expert Specialist
What you are looking for is called "cascading combo boxes" and we have an article about that at http://bytes.com/topic/access/insigh...mbo-list-boxes

Basically when having manufacturers related to models, the relation should also be in your database and adding a model should also include adding a (link to) the manufacturer.

Nic;o)
Dec 14 '08 #2
ZaphodBBB
54 New Member
Thanks for the article Nico I'll have careful read of it. I have used before where you have one combo define the values that will appear in another, however in this case the database started with empty tables so to begin with everything needed to be entered manually. However there is a little data there now so it would be nice not to have to keep entering all and every item.

Thanks Mike
Dec 14 '08 #3
nico5038
3,080 Recognized Expert Specialist
Hi Mike,

The "alternativ e" I often use for "plain" reference fields is to define the combo box with a SELECT DISTINCT <field> from tblX.
Thus e.g. a city can be selected easily when entered once.
This will however to be limited to "plain" fields, as it's not useful when you also need e.g. an address and/or phone number from a supplier.

Personally I use different forms for manipulation of tables (read "objects").
So in your case I would have a separate form for departments, supplier, etc.
On the frmAdd_Equipmen t I would only re-use the other tables and give an option to "jump" to the frmAddDepartmen t, etc. Using the NotInList property of the combo box.

Nic;o)
Dec 14 '08 #4
ZaphodBBB
54 New Member
Thanks Nico

I had never heard of the Not In List property so thats something I have learned today.

I do have seperate forms for the other Fields such as AddManufacturer and Add Supplier etc but I wanted to make it quick and easy to add new equipment from one form , so I put all the comboboxes on the form with Add New cmdButtons next to each combo box that will take you to the relevant form should you need them. But it's beginning to get a little messy so I may end up doing as you suggest.

Cheers
Mike
Dec 15 '08 #5
ZaphodBBB
54 New Member
Hi Nico

I just had a quick read of the Cascading Comboboxes article. Do you know if you can load more than one column via code into the second comboBox?

i.e. Say Combobox 1 was the CompanyID and Company Name
could you code the after update event of Combobox 1 so that it updates Combobox 2 with say EmployeeID and Employee Name?

Thanks Mike
Dec 15 '08 #6
nico5038
3,080 Recognized Expert Specialist
Glad to see you're interested in learning something new :-)

There's no limit to the number of columns. Just make sure that the correct WHERE is implemented.

A complete sample how to use the NotInList to add a new record is available here:
Use NotInList Event to Add a Record to Combo Box

Nic;o)
Dec 15 '08 #7
ZaphodBBB
54 New Member
Thanks Nico

Just read the article and it appears it could be very useful. Funny how you sometimes dont notice things, as I'd never even noticed that in the events list for Combos.

Thanks
Mike
Dec 16 '08 #8
nico5038
3,080 Recognized Expert Specialist
Took me also several months to detect this mechanism and that's the beauty of sites like this, it can save you a lot of time :-)

Success with your application !

Nic;o)
Dec 17 '08 #9

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

Similar topics

2
2999
by: Dave N | last post by:
I have a combo box that displays the names of all the users in my "Users" table. I set the RowSource to a Query from the "User" and "Project" tables. I can select any name from the list and that name comes up in the combo box on the form. Everything works fine this way I just want to automatically put the user name in the combo box display....
3
3198
by: mal | last post by:
Sorry for repost - system added to another subject for some reason Have tried numerous ideas from the group to solve this one. It is such a simple example that it should be straightforward ! I just want to add a new item to a combo that has data from a file, by typing in the new value , adding to the file and the requerying to get the new...
6
3746
by: Ron L | last post by:
I have a dataset whose source is a SQL 2k stored procedure that I am trying to display in a datagrid. This datasource has 4 columns that I am interested in here, a text column and 3 value columns corresponding to permissions to certain data classes. I want to put the permission values in combo boxes in the grid and instead of displaying the...
3
5330
by: Mike Jakes | last post by:
I hope that someone can offer a little advice on this one - I've searched the group but can't find an answer. I think that I'm doing something really stupid or missing something trivial, but see what you can make of this... I have a main form "Events" that contains a tab control. The tab control has 7 pages. The 7th page (named "Boats")...
0
2917
by: Jeremy Wallace | last post by:
Folks, Here's a write-up I did for our developer wiki. I don't know if the whole rest of the world has already figured out how to do this, but I hadn't ever seen it implemented, and had spent a lot of time trying to figure it out, over the years. It finally dawned on me a couple of weeks ago how to do this. A couple of notes: 1) This is...
8
2192
by: AA Arens | last post by:
Hi I do have a products table and products-parts table in my Access 2003 database and log all services into a form. I do have at least the following two combo boxes on my form: - Choose Product where as the Row Source (See properties): SELECT tblProducts.ProductName, tblProducts.ProductName FROM tblProducts ORDER BY ProductName;
4
64549
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 determines the available options in the other. TERMINOLOGY Row Source: The table/query from which the Combo Box or List Box gets its values. Note:...
1
2574
by: =?Utf-8?B?bWZt?= | last post by:
I have recently migrated to VS.Net 2005, and I am struggling to do something very basic with the combo box. I want to manually loop through a data table and add both the display text and the value manually. The reason I cannot bind the combo box to my data table is that there are more than one field that I want to combine to be the display...
2
3262
by: Dave | last post by:
I have 3 tables of information feeding into 4 combo boxes on my main form (DR Form). I have as many list boxes (acting as text boxes) as there are fields in each one of the 3 tables. Once selecting from the combo box, I have all the combo boxes, using afterupdate, populating their respective list boxes. These text boxes are directly...
0
7658
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7579
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...
0
8101
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6238
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...
1
5479
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...
0
5204
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3631
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...
1
2077
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
0
912
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.