Filter Records Displayed on Form

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
 
G

Graham Mandeno

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
 
E

eacollie

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





.
 

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