Two questions about combo boxes

G

Guest

I have two questions about combo boxes - thanks if you can help out...

1. I want to be able to type the first letter in a combo box and if my
selection is not the first choice, I would like to type the second letter and
have the next selection show in the combo box. For example: I have a list
of states, I want NY, I type N and NJ comes up, I want to then type the Y and
get to NY. How do I do that?

2. If I have two existing tables that I use for row source in combo boxes.
Is there a way to base one combo box on the other and limit what the second
combo box shows based on the first combo box? For example: I have Regions
and I want to attach certain states to a region. So I want to be able to
select North Central Region and to have, WA, OR, ID show in the States combo
box. How do I do that?
 
F

fredg

I have two questions about combo boxes - thanks if you can help out...

1. I want to be able to type the first letter in a combo box and if my
selection is not the first choice, I would like to type the second letter and
have the next selection show in the combo box. For example: I have a list
of states, I want NY, I type N and NJ comes up, I want to then type the Y and
get to NY. How do I do that?

2. If I have two existing tables that I use for row source in combo boxes.
Is there a way to base one combo box on the other and limit what the second
combo box shows based on the first combo box? For example: I have Regions
and I want to attach certain states to a region. So I want to be able to
select North Central Region and to have, WA, OR, ID show in the States combo
box. How do I do that?


#1) Set the Combo box AutoExpand property to Yes.

#2) Leave the second combo box RowSource property blank.
Code the AfterUpdate event of the first Combo (Combo1) something like
this:

Me!Combo2.Rowsource = "Select TableName.State from TableName Where
TableName.Region = '" & Me!Combo1 & "' Order By TableName.State;"

The above assumes you have a table with a Region field and a State
field. Change the table and field names to whatever your actual table
and field names are.
 
J

Jeff L

Answer to question 1
Look at the properties of your combo box. Click the Format tab. There
should be a setting there called Auto Complete. Put Yes for that
setting.

Answer to question 2
You need to have a Regions table (RegionID, RegionName) that list all
your regions. Then in your States table, you need a field for
RegionID. Put the correct RegionID for each state. On your form, make
a combo box for the region. It needs to have two columns, the bound
column is 1, and the column widths are 0;1. For your State combo, the
RowSource should be something like:
Select StateName from tblStates where RegionId =
Forms!YourFormName!Region

In the After Update event of the Region, go into the code window and
put Me.State.Requery

Hope that helps!
 
G

Guest

Ok 1 more question about combo boxes:

I want to press N to move through my state list, going from NJ, NM, NV to
NY. I don't want it to add a second N, just keep moving down through the
list. Is there a way to do that?
 
F

fredg

Ok 1 more question about combo boxes:

I want to press N to move through my state list, going from NJ, NM, NV to
NY. I don't want it to add a second N, just keep moving down through the
list. Is there a way to do that?

Not using a combo box.
Change the combo box to a List Box and that method should work
 

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