473,545 Members | 2,085 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Populating Multi-Column Combobox

77 New Member
Hi,

Here's another problem that I came up with:

I have a combobox in a form with 2 columns. What I need is the following:

1. The combobox to be cleared on form_load (not only the text, but also the list)
2. The combobox to be populated with two fields in a different database (I'm pulling these two lists using a recordset and the data is ready to be fetched into the combobox)... I'm not sure how to populate the two different columns of the combobox and then how to refer to them?
3. On any change in the records, need to refresh the combobox..

Please let me know if any more inputs are required from me to make it simpler..

Thanks in advance........ :-)
Aug 29 '08 #1
4 4260
hjozinovic
167 New Member
Hi,

Here's another problem that I came up with:

I have a combobox in a form with 2 columns. What I need is the following:

1. The combobox to be cleared on form_load (not only the text, but also the list)
2. The combobox to be populated with two fields in a different database (I'm pulling these two lists using a recordset and the data is ready to be fetched into the combobox)... I'm not sure how to populate the two different columns of the combobox and then how to refer to them?
3. On any change in the records, need to refresh the combobox..

Please let me know if any more inputs are required from me to make it simpler..

Thanks in advance........ :-)
1. To clear the combobox and the list in it, put a code like this in OnLoad event of the form:
Expand|Select|Wrap|Line Numbers
  1. Me!cboYourCombo = Null
  2. Me!cboYourCombo.RowSource = ""
2. This concerns me a little regarding two 'separate lists' but I hope you know how to get the query showing the list you need to have in your combo box.
If I assume you have that query created and it's name is qryMyList then put a code like this in the event you want to trigger the population of your combobox:
Expand|Select|Wrap|Line Numbers
  1. Me!cboYourCombo.RowSource = "qryMyList"
To reffer to columns of your drop-down list use this code:
Expand|Select|Wrap|Line Numbers
  1. Me!cboYourCombo.Column(Index)
Index is a number ranging between 0 (first column) and total number of columns in the list-1. Columns are indexed starting with zero.
If you have three columns then indexes are 0,1,2
3. In the event afterUpdate of your 'records' put a code like this:
Expand|Select|Wrap|Line Numbers
  1. Me!cboYourCombo.requery
Aug 29 '08 #2
yaaara
77 New Member
Thanks for the detailed explaination buddy..

However, when I follow the tip in point 2, I get an error "type mismatch"

Apparantly, trying to pass the recordset directly as recordsource is producing this error... Any clues?

Thanks.
Aug 29 '08 #3
NeoPa
32,563 Recognized Expert Moderator MVP
A Recordset cannot be used to populate the ComboBox directly (except in a slow and painful way).

Use the name of a QueryDef or even some SQL for this.

Show the code you're using if you don't think this is your problem, but I suspect it is.

Why do you want to load the data up piecemeal as you describe from your Recordset?
Aug 29 '08 #4
yaaara
77 New Member
I think I figured this out..

Instead of passing the recordset directly, I stored it as a string and then passed the string... Works like a jiffy...

Thanks for the assistance all... Highly appreciated :-)
Aug 29 '08 #5

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

Similar topics

2
1651
by: enigma261 | last post by:
Hi, I am a XML beginner. I need some guidance in intrepreting a XML file and then populating my object model. Following is an example of the XML file .. <Tom> <Version>x.0</Version>
2
2669
by: Janus | last post by:
Hello. I need a little advice for populating the treeview control. I dont want my application to hang while populating the treeview, there is a lot of data what's the best approach? Maybe something eventbased but how? please help... Should I avoid populating the treeview control using a thread?
1
2464
by: msnews.microsoft.com | last post by:
I'd like to hear your thoughts on best methods for populating drop down list controls. I have states and countries drop down lists that don't change often, so naturally I "hard code" them in the aspx page. But the problem is these tend to really slow the development -- it takes up to 15 seconds for the page to come up in VS.NET design...
4
1131
by: sck10 | last post by:
Hello, I have two dropdown objects that I want to use the same datasource for each. I tried the following, but it doesn't populate the second dropdown. Do I need to close the OleDbDataReader and then re-open it to populate the second dropdown object? Thanks in advance, sck10
5
2267
by: | last post by:
Trying to learn about manipulating collections of objects, and populating these objects dynamically from datasources. Could someone post a code sample that shows the following: Instantiating a collection object -- say, a dictionary. Populating that collection object with custom objects, say, Person. What I really want to see is how to...
8
2078
MattFitzgerald
by: MattFitzgerald | last post by:
Please Help! I have a form in this form I have a list box , I have set the property of Multi Select to Extended I also have a query in this query I have a field on which I wish to filter by my Multi Select List Box. I have tried the following 3 things in the criteria of my query with no sucess:-
1
12838
by: dkohel | last post by:
I have 2 list boxes on my form. I am trying to populate listbox B with the selection from listbox A. I have set multi-select in both boxes to Extended... The user will select the items from listbox A and click an Add button that will then copy the items to listbox B. Then for each item in B, I need to add them to a database. If there...
3
2545
by: Brock | last post by:
I am trying to populate a Crystal Report from data in my DataGrid. The reason for this is that I want the user to be able to change values without updating the database, but still have their report reflect the values they anticipate committing to see hypothetical totals of columns from a set of records. These records are displaying properly...
6
1728
rezme
by: rezme | last post by:
Allow me to preface this with a disclaimer: I'm self taught in C#, basically I type code in from what I've found on the web, and try to get it to do what I want it to. I'm sure there's a lot of us out there, but I really know very little of the terminology. If I'm in error on something, please feel free to correct me. That being said, I've...
0
1363
by: Eric B. | last post by:
I am populating a DataGrid with many rows. As it is populating I see the scrollbar flying but no rows pop up until it is finished. Is there a way to make each row draw as soon as it is finished populating? Thanks! Eric B.
0
7468
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
7401
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
7656
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. ...
1
5329
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
4945
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
3450
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...
0
3443
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1884
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
1
1014
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.