populating a listbox from a combo box selection

alexi

Registered User.
Local time
Today, 10:35
Joined
Feb 26, 2003
Messages
65
gday,

i have completely forgotten how to do this but what i need to do is select something from a combo box, and then have all the related fields be displayed in the list box. i just cannot remember for the life of me.
any help would be appreciated

cheers
 
alexi,

You can use the AfterUpdate event of the combobox to:

Code:
Me.lstListBox.Rowsource = "Select SomeField " & _
                          "From   YourTable " & _
                          "Where  SomeKey = '" & Me.cboYourCombo & "'"
Me.lstListBox.Requery

This assumes that your key field is character, for a numeric
field, remove the single-quotes.

Wayne
 
Thanks for that but i cant get it to work. I know there was another way to do this but i still cannot remember. iT was putting something in the listbox to link it to the combo.
Any other ideas?

this is what i have put in.

Me.Symptom.RowSource = "Select SrchID " & _
"From Fixs " & _
"Where SrchID = '" & Me.Problem & "'"
Me.Symptom.Requery
 
Alexi,

Can you post a sample db?

Tools --> Database Utilities --> Compact/Repair
ZIP
Then post

Wayne
 
sorry for the late response.
what i have done is created a query for the listbox, and that works.
Except with the criteria underneath the Primary Key field of the table, the rest of the fields dont show up in the listbox. when i take the criteria out, they showup again.
any ideas?
 
Alexi,

Except with the criteria underneath the Primary Key field of the table, the rest of the fields dont show up in the listbox. when i take the criteria out, they showup again.

The rest of the fields don't show up.

The criteria is not going to affect how many fields show up, just
records. Are you sure you don't mean rows (or records)?

Wayne
 
i mean fields.
in the query i hvae six fields. in the listbox i have the column count set to six. with the crietria out, the columns are filled. when the criteria is in, onlyy the column with the criteria on it is filled.
 
alexi,

I'd have to see this. If you have a criteria, it will return
some number of rows, with all other fields blank. If you take
out the criteria, you get ALL the rows and all the fields are
filled in.

Have you tried different criteria? I bet you that with no
criteria there are still parts of your table that have all
of those empty fields.

If you just open your table and sort on various columns do you
find the nulls. And find a record with all the fields filled
and select that for the criteria.

Wayne
 
Hi,

Can you post the SQL of your query (View, SQL) here?
Maybe you've to check the column-widths, for six fields you can separate the widths with ; ie: 0.5;0.5;0.5;0.5;0.5;0.5
 
WayneRyan said:
Code:
Me.lstListBox.Rowsource = "Select SomeField " & _
                          "From   YourTable " & _
                          "Where  SomeKey = '" & Me.cboYourCombo & "'"
Me.lstListBox.Requery
Wayne,
Changing the Rowsource doesn't need a requery I thought?

Greetz
 

Users who are viewing this thread

Back
Top Bottom