Automatically populate combo box

G

Guest

Hello, I am a newbie to Access. I am using Access 2002.

I need one combo box to be populated with info depending on a selection made
in another combo box.

Combo1 contains Product Category Information
Combo2 contains Product Name Information

If I select "Conventional" in Combo1, it needs to populate Combo2 with all
and only poroducts that relate to "Conventional", simmilarly, if I select
"Intelligent" from Combo1, only and all products that relate to Intelligent
will show in Combo2.

I have 3 Tables

Table1: tblStock which has (amonsgt other things) CategoryID, CategoryName,
StockID and StockName. This is where all of the stock info is held.

Table2: tblCategory which has CategoryID and CategoryName. Through a
lookup, this allows the user to select a category from a combo Box when
entering info into tblStock

Table3: tblOrders which has lots on it, but primarilly, it allows user to
input order info.

My question is, what do I need to do to make all of these table etc work.

My understanding of VBA Code is extremely limited, so please assume I know
nothing and respond as you would to an idiot.

Hoping you can help, Thanks in advance.
 
F

fredg

Hello, I am a newbie to Access. I am using Access 2002.

I need one combo box to be populated with info depending on a selection made
in another combo box.

Combo1 contains Product Category Information
Combo2 contains Product Name Information

If I select "Conventional" in Combo1, it needs to populate Combo2 with all
and only poroducts that relate to "Conventional", simmilarly, if I select
"Intelligent" from Combo1, only and all products that relate to Intelligent
will show in Combo2.

I have 3 Tables

Table1: tblStock which has (amonsgt other things) CategoryID, CategoryName,
StockID and StockName. This is where all of the stock info is held.

Table2: tblCategory which has CategoryID and CategoryName. Through a
lookup, this allows the user to select a category from a combo Box when
entering info into tblStock

Table3: tblOrders which has lots on it, but primarilly, it allows user to
input order info.

My question is, what do I need to do to make all of these table etc work.

My understanding of VBA Code is extremely limited, so please assume I know
nothing and respond as you would to an idiot.

Hoping you can help, Thanks in advance.

Leave the second combo box's (combo2) RowSource blank.
Set it's RowSourceType to Table/Query

Assuming the bound column of Combo1 is a numeric Datatype CategoryID
code the Combo1 AfterUpdate event something like this:

Combo2.Rowsource = "Select YourTable.[FieldName] from YourTable Where
YourTable.[CategoryID] = " & Me![ComboName] & " Order by [FieldName];"

If the bound column of Combo1 is Text datatype [CategryName] then
Combo2.Rowsource = "Select YourTable.[FieldName] from YourTable Where
YourTable.[CategoryName] = '" & Me![ComboName] & "'Order by
[FieldName];"

Change the field and table names to the actual ones used.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top