combo box record source

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
 
D

Dale Fye

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
 

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