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

Show results of union query in combobox

100+
P: 284
I had two tables, one new customers and the other new suppliers.

Now I want to show all the customer and suppliers in one combo box.

I am using a recordset by coding

Expand|Select|Wrap|Line Numbers
  1.  
  2. recordset1.open "select name from newcustomer union all select name from newsupplier" 
  3. combobox1.rowsource = recordset1
  4. combobox1.listfield = "name"
  5.  
When I use a union clause it does not show the name in combo box. When I use only one table it works.

Remember I already made the name columns of both table as primary key so how can I show names from two or more tables in one combo box?
Dec 22 '07 #1
Share this Question
Share on Google+
10 Replies


Ali Rizwan
100+
P: 927
Why don't you use a Do While loop to add contents in combo?

If you don't know the procedure I'll send it to you.

Eid Mubarik

>> ALI <<
Dec 22 '07 #2

debasisdas
Expert 5K+
P: 8,127
Open separate recordsets and add to the combo in a loop.
Dec 22 '07 #3

100+
P: 284
i will try to make a loop
Dec 22 '07 #4

Ali Rizwan
100+
P: 927
i will try to make a loop
Expand|Select|Wrap|Line Numbers
  1. Adodc.Recordset.MoveFirst
  2.  
  3. Do While Not Adodc.Recordset.EOF
  4.   Combo1.Additem (Adodc.Recordset.Fields (0))
  5.   Adodc.Recordset.MoveNext
  6. Loop
This is for Adodc. You can use this for adodb also.

Regards

>> ALI <<
Dec 22 '07 #5

100+
P: 284
first i made a view containg all the name of customers and
supplier and then make a adodc connection to it

and when i write the code its give me the error
"object variable or with block variable not set"

what wrong with it



Expand|Select|Wrap|Line Numbers
  1. Adodc.Recordset.MoveFirst
  2.  
  3. Do While Not Adodc.Recordset.EOF
  4.  
  5. Combo1.Additem ( Adodc.Recordset.Fields (0))
  6. Adodc.Recordset.MoveNext
  7.  
  8. Loop
This is for Adodc u can use this for adodb also

Regards

>> ALI <<
Dec 22 '07 #6

Ali Rizwan
100+
P: 927
first i made a view containg all the name of customers and
supplier and then make a adodc connection to it

and when i write the code its give me the error
"object variable or with block variable not set"

what wrong with it
Replace Adodc with Adodc1.
OK

Regards

>> ALI <<
Dec 22 '07 #7

100+
P: 284
i had used the name adodc1 still its give error.
now , instead of using this
i had made a new table which contain all the name of
customers and suppliers
so this fulfill my task

Replace Adodc with Adodc1.
OK

Regards

>> ALI <<
Dec 23 '07 #8

Ali Rizwan
100+
P: 927
i had used the name adodc1 still its give error.
now , instead of using this
i had made a new table which contain all the name of
customers and suppliers
so this fulfill my task
Is the problem solved or not?
Or ill make an example of it?

Regards

>> ALI <<
Dec 23 '07 #9

100+
P: 284
problem is solved

thanks



Is the problem solved or not?
Or ill make an example of it?

Regards

>> ALI <<
Dec 24 '07 #10

debasisdas
Expert 5K+
P: 8,127
We are glad to know that the problem is solved by help of our memebers.

Feel free to post further questions in the related forum only.
Dec 24 '07 #11

Post your reply

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