Filter Records Displayed on Form

  • Thread starter Thread starter eacollie
  • Start date Start date
E

eacollie

I am trying to create a form that will display filtered
records from a table. I want to have option buttons that
can be selected to change the record source of the form.
How can I do this?

Thanks
 
In the AfterUpdate event of the option group, use a case statement to set a
filter string depending on the criteria you require. For example:

Dim sFilter as String
Select Case opgFilter
Case 0 'show all records
' do nothing
Case 1 'fldDate older than 30 days
sFilter = "fldDate<Date()-30"
Case 2 'CustName begins with "A"
sFilter = "CustName like 'A*'"
End Select
Me.Filter = sFilter
Me.FilterOn = len(sFilter)>0
 
Thank you, Graham!
-----Original Message-----
In the AfterUpdate event of the option group, use a case statement to set a
filter string depending on the criteria you require. For example:

Dim sFilter as String
Select Case opgFilter
Case 0 'show all records
' do nothing
Case 1 'fldDate older than 30 days
sFilter = "fldDate<Date()-30"
Case 2 'CustName begins with "A"
sFilter = "CustName like 'A*'"
End Select
Me.Filter = sFilter
Me.FilterOn = len(sFilter)>0





.
 
Back
Top