Populate Combo Box Based on Filtered Data (1 Viewer)

rede96

Registered User.
Local time
Today, 05:02
Joined
Apr 2, 2004
Messages
134
Hi All,

I have a combo box which is used to find and select records in a continuous form.

I'm to figure out just how to populate the combo box with records in after a filter has been applied to the form, so the combo box only shows the records being displayed and not all the records.

I am using the form filter to set the filter.

Can anyone help please?:confused:
 

Ranman256

Well-known member
Local time
Today, 00:02
Joined
Apr 9, 2015
Messages
4,337
you would have to rebuild the combo query based on the filter.

Code:
Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
if  me.filterOn then
  cboBox.rowsource = "select [field] from table where " & me.filter
else
   cboBox.rowsource = "select [field] from table 
endif
End Sub
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:02
Joined
May 7, 2009
Messages
19,249
If youre combo has same table as with your form you apply the filtet to your combo bychanging its rowsource filtered. See the code behind the form.
 

Attachments

  • sample.zip
    27.8 KB · Views: 47

rede96

Registered User.
Local time
Today, 05:02
Joined
Apr 2, 2004
Messages
134
you would have to rebuild the combo query based on the filter.

Code:
Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
if  me.filterOn then
  cboBox.rowsource = "select [field] from table where " & me.filter
else
   cboBox.rowsource = "select [field] from table 
endif
End Sub

If youre combo has same table as with your form you apply the filtet to your combo bychanging its rowsource filtered. See the code behind the form.

Thanks to both of you. The record source for the form already has a WHERE clause, but I think you've shown me a way to edit the combo row source when I apply and remove the filter.

Thanks!
 

Users who are viewing this thread

Top Bottom