Change rowsource on combobox in OnEnter event
- From: Doug <Doug@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 3 Apr 2009 10:16:25 -0700
I have a combo box on a tab object of an Access 2002 form that contains a lot
of records (30000+). To increase the form speed, I set the original
rowsource for the combo box to only the record bound to that control so only
1 record is retrieved (because it is rarely changed after it is added). If
the user enters the combobox again, I have code in the On Enter event to
select from the DB again for all the records so the user can select any
record they would like.
My OnEnter event is as follows:
Private Sub cbobillclientcode_Enter()
strsql = "SELECT tblClient.clientcode, tblClient.lastname + ', ' +
tblClient.firstname AS client, tblCompany.intname " & _
"FROM tblClient INNER JOIN " & _
"tblCompany ON tblClient.companycode = tblCompany.companycode "
"WHERE tblclient.status = 'Active' " & _
" ORDER BY Client "
Me.cbobillclientcode.RowSource = strsql
I would expect the rowsource to change and the combobox to requery but it is
not changing. It still only contains the one record. I have checked the sql
in query analyzer and that works fine.
- Prev by Date: change field format of a query on a form with vba
- Next by Date: Checkboxes on a subform not giving consistent results
- Previous by thread: change field format of a query on a form with vba
- Next by thread: RE: Change rowsource on combobox in OnEnter event