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

List Box Population :))

bimos
P: 11
New day new Problem


I have a Combo Box - a query - and a list box
What I want to do is:
User selects a value in the combobox the query runs and the output is shown in the list box
I have managed to output the first result but when i select another value in the ComboBox ---> nada ....I get the same result!
I know there is a after update issue but I'm a no coder :( still I'll do my best if needed!

Thanks,
Alex
Feb 21 '07 #1
Share this Question
Share on Google+
7 Replies


Rabbit
Expert Mod 10K+
P: 12,366
Well it would help if you would post your code.
Feb 21 '07 #2

MMcCarthy
Expert Mod 10K+
P: 14,534
New day new Problem


I have a Combo Box - a query - and a list box
What I want to do is:
User selects a value in the combobox the query runs and the output is shown in the list box
I have managed to output the first result but when i select another value in the ComboBox ---> nada ....I get the same result!
I know there is a after update issue but I'm a no coder :( still I'll do my best if needed!

Thanks,
Alex
Hi Alex

Have a look at this tutorial on Cascading combo/List Boxes . The same rules hold true for a combobox and a listbox.

Mary
Feb 22 '07 #3

bimos
P: 11
Well I have taken a look at the Tutorial great one! The problem is that my Combo and my list box are bound to FK fields in one table :(

Expand|Select|Wrap|Line Numbers
  1. Private Sub ComboBOX_AfterUpdate()
  2. With Me![List12] >>>Is my list Box
  3. If IsNull(Me!ComboBOX) Then
  4. .RowSource = " "
  5. Else
  6. .RowSource = "SELECT [Name]" & _
  7.              "FROM CompanyContactQ " & _ >>>The CompanyContactQ Is my query
  8.             "WHERE criteria" = " & Me!ComboBOX"
  9. End If
  10.     Call .Requery
  11.   End With
  12. End Sub

Hope this makes sense!
Alex
Feb 22 '07 #4

MMcCarthy
Expert Mod 10K+
P: 14,534
Hi Alex

1. What is the row source and control source of ComboBox Query
2. What is the control source of List12?
3. Post the SQL for CompanyContactQ query.


Mary
Feb 22 '07 #5

bimos
P: 11
Hi Alex

1. What is the row source and control source of ComboBox Query
2. What is the control source of List12?
3. Post the SQL for CompanyContactQ query.


Mary

Silly Me :) should have done this in the 1st place

ComboBox rowsource ->SELECT[List of Companies].[company key];[List of Companies].[Company Name] FROM[List of Companies]
The Control source is Company Key

List Box-> SELECT CompContactQ.Name FROM CompContactQ;
The control source is Contact Key


The Query SQL is :

SELECT [Company Contacts].Name
FROM[List of Companies] INNER JOIN [Company Contacts] ON[List of Companies].[Company Key] = [Company Contacts].[Company Key]
WHERE ((([List of Companies].[Company Name])=[Forms]![Jobs Best]![Task Form V3]![tragaci]));

I have a form Jobs Best and a sub form Task Form V3
tragaci is the comboBox

tragaci = trigger :)))) A bit messy I know

Hope you can sort this one for me;
Many thanks
Alex
Feb 22 '07 #6

MMcCarthy
Expert Mod 10K+
P: 14,534
OK Alex

Forget the query.

ComboBox rowsource ->SELECT[List of Companies].[company key];[List of Companies].[Company Name] FROM[List of Companies]
The Control source is Company Key
This is fine.

Expand|Select|Wrap|Line Numbers
  1. List Box-> SELECT [Name] FROM [Company Contacts]  WHERE [Company Key]=[Forms]![Jobs Best]![Task Form V3].Form![tragaci]));
  2. The control source is Contact Key 
  3.  
Change listbox to this and dump the query.

Now go back to the combobox control and create an AfterUpdate event with just the following line of code.

Expand|Select|Wrap|Line Numbers
  1. Private Sub tragaci_AfterUpdate()
  2.    Forms![Jobs Best]![Task Form V3].Form![ListboxName].Requery
  3. End Sub
  4.  
I'm assuming they are both on the same subform.

Mary
Feb 22 '07 #7

bimos
P: 11
I hate it when I can't do it my self....Thanks a lot, it works like a charm!
I had another solution for unbound Combo and List Boxes together with a query...you can add a refresh button so every time you update the comboBox you hit the refresh so you get a requery in the list BOX -- just a stupid ideea "but" I was about to go ahead with it :))

Thank you!

PS: if you have a banner please send it my way :)
Feb 22 '07 #8

Post your reply

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