combo box record source

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

Ideally I would like to be able to change the
recordsource of a combobox at runtime. Is this possible
and if so an idea of the required code would be
appreciated.

Tom
 
Yes, it can be done easily.

For example, you might have a combo box that lets you
select one of several fields from your table. Then, you
have a second combo box that lists the unique values from
that field.

Private Sub Combo1_AfterUpdate

Dim strSQL as string
strSQL = "SELECT DISTINCT " & me.combo1 _
& " FROM yourTable"
me.combo2.rowsource = strsql
me.combo2.requery

End sub
 
Back
Top