can't get a combobox to show the value i want

gillbates21

Registered User.
Local time
Today, 23:27
Joined
Apr 8, 2006
Messages
15
i searched for similar combobox features, nut didn't find any that helped.

i have 2 unbound combos that get heir values from different tables

first combo1 gets its values from a query
SELECT [tbl_music].[MID], [tbl_music].[Artist], [tbl_music].[Song], [tbl_music].[CID] FROM tbl_music;

combo2 gets values from
SELECT [tbl_category].[CID], [tbl_category].[Category] FROM tbl_category;

IDs are autonumber and primary
The CID fields in the tables are in a 1..* relationship

Both are constructed with the wizard and the ID columns are hidden.

What i need is:
when selecting something from combo1, the combo 2 should show the right category for that song.

Hope i explained clearly enough.
I tried to use the dlookup function, but i get error 94, invalid use of null.
i'm using the afterupdate event.

I can update a textbox text, but can't do so with the combobox value.

Any ideas what i'm donig wrong :confused: :confused: :confused:
 
Search this forum for information on "cascading combo boxes" this should provide you with the answer. If you have any further problems please repost...
 
It's not exactly cascading combos...

I already have all the right values in the combos.

OK, i try to explain:
combo1 has values from table music table (first colum is MusicID and hidden)

the values are like "artist ; song" (2 columns)

combo2 has values from table category (first column is CategoryID and hidden)
the values are "A", "B" and "C"

the music table has a CID column, where the right category's ID is stored. What I need is:
when coosing a value from combo1, the combo2 needs to show the current category letter for that artist-song (without dropping down).

combo2 values do not get filtered.

so my problem is how to reference it the right way...

Hope its clearer now.
 
So for clarity, combobox 1 shows the artist, song, from the music table. The music table also has a field that stores the category.

You want this category to appear in a separate combo box?

If that is a correct interpretation,
Then why not just add another column to your combox 1 to display the category?

reason for editing : didn't make much sense first draft!
 
Last edited:
you are right, the category needs to be in a separate combo.

the music table has the category field set to numeric, and the category table has the corresponding string values.

the second combo is needed to change the songs category (using UPDATE query under a commandbutton)
 
Last edited:
Ah, now all becomes clear!

The problem is as I see it you are going about it backwards! The normal way would be to find the particular record within a form linked to the relevant table, have a combo box bound to the category field, which was also linked to a look up table to look up the relevant category.

What you need to do is generate a form based on that particular table, add a combo box with which to look up the particular record you want. The combo box wizard will provide this functionality for you.

Then have on your form another combo box "bound" to the category field of the underlying table, have the record source of the combo box set to the look up table containing the various categories.

If you have any problems post back.
 
And the correct way !

Well done!

I thought you might like to see the correct way to do it ! :)
 

Attachments

Thanks :)

Still, there was 1 line missing... in form load event
Combo2.value = null
 
gillbates21 said:
Thanks :)

Still, there was 1 line missing... in form load event
Combo2.value = null

Sorry , don't follow you. Would you like to explain the purpose of that statement?
 

Users who are viewing this thread

Back
Top Bottom