Filtering Source for Combo Box

K

Kevin Sprinkel

A table named tblSteelData is being used as the source for
a combo box in a multiple record subform.

tblSteelData
=============
SteelTypeID AutoNumber
Type N, FK
Dimensions T
LBPerLF N
SFPerLF N

The Type and Dimensions identify the cross-sectional shape
and size, respectively. Rather than show all records, I'd
like the user to input the type from one combo box, and
display the dimensions for the tblSteelData records of
that type in a second combo box. Once the dimensions are
selected, I want to store the SteelTypeID associated with
these two field values in the underlying table.

If this "split" combo box is possible, I'd appreciate any
help implementing, including how to filter the records for
the second combo box.

Thanks for all assistance.

Kevin Sprinkel
 
M

Michel Walsh

Hi,



Change the RowSource appropriately, something like (in the gotFocus
event, as example):


Dim str As String

str="SELECT SteelTypeID, Type, Dimensions, LBPerLF, SFPerLF FROM
tblSteelData "
str=str & " WHERE TRUE ""
str=str & ( " AND Type=" + Me.Type )

' Debug.Print str

If Me.ComboBoxName.RowSource <> str then
Me.ComboBoxName.RowSource=str
End If



Hoping it may help,
Vanderghast, Access MVP
 

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