By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,591 Members | 629 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,591 IT Pros & Developers. It's quick & easy.

Populating Multi-Column Combobox

P: 77
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
Share this Question
Share on Google+
4 Replies


100+
P: 167
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

P: 77
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
Expert Mod 15k+
P: 31,419
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

P: 77
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

Post your reply

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