Hi Luis:
This is the way I do it- I setup a query statement then I reset the form's
recordsource function. Here's an example of actual code:
' note that the select choices uses SQL queries. Don't leave out or put in
any
' extraneous periods, commas, or use any concanations that give you errors!
Select Case Forms![*LEDGER FORM]![EmbLedger].Form![FilterOption].value
Case "All Records"
SQLStmt = "SELECT ACCOUNTS.* FROM ACCOUNTS WHERE (ACCOUNTS.DATESVC)
Date()-800 AND ACCOUNTS.ACCT = FORMS![*LEDGER FORM]![ACCT] ORDER BY
ACCOUNTS.DATESVC;"
Case "1-6 Months"
SQLStmt = "SELECT ACCOUNTS.* FROM ACCOUNTS WHERE
(((ACCOUNTS.DATESVC) > Date()-183) AND ACCOUNTS.ACCT = FORMS![*LEDGER
FORM]![ACCT]) ORDER BY ACCOUNTS.DATESVC;"
Case "7-12 Months"
SQLStmt = "SELECT ACCOUNTS.* FROM ACCOUNTS WHERE
(((ACCOUNTS.DATESVC) >= Date()-366 And (ACCOUNTS.DATESVC) < Date()-182) AND
ACCOUNTS.ACCT = FORMS![*LEDGER FORM]![ACCT]) ORDER BY ACCOUNTS.DATESVC;"
Case "13-18 Months"
SQLStmt = "SELECT ACCOUNTS.* FROM ACCOUNTS WHERE
(((ACCOUNTS.DATESVC) >= Date()-548 And (ACCOUNTS.DATESVC)<Date()-365) AND
ACCOUNTS.ACCT = FORMS![*LEDGER FORM]![ACCT]) ORDER BY ACCOUNTS.DATESVC;"
Case "19-24 Months"
SQLStmt = "SELECT ACCOUNTS.* FROM ACCOUNTS WHERE
(((ACCOUNTS.DATESVC) >= Date()-731 And (ACCOUNTS.DATESVC) < Date()-547) AND
ACCOUNTS.ACCT = FORMS![*LEDGER FORM]![ACCT]) ORDER BY ACCOUNTS.DATESVC;"
Case "<24 Months"
SQLStmt = "SELECT ACCOUNTS.* FROM ACCOUNTS WHERE
(((ACCOUNTS.DATESVC) < Date()-730) AND ACCOUNTS.ACCT = FORMS![*LEDGER
FORM]![ACCT]) ORDER BY ACCOUNTS.DATESVC;"
End Select
Forms![*LEDGER FORM]![EmbLedger].Form.RecordSource = SQLStmt
Exit Sub
What exactly are you basing you filter on? Numbers, text, dates....
Regards,
Al
(check out my free MS Word EMR Project, downloadable at
http://www.emrupdate.com/freestuff/alborgesmd.aspx)
Hello.
I have a form with a combo box which row source is a table. I'd like to
add
a string to that row source ("ALL") to work as a wildcard on a filter.
This
table is built every day by a make table query. How can i add this string?
The second question i have is to make this wildcard work. What i'd like is
that when the user chooses the "ALL" string a certain query should return
all
the records of a table. If the user chooses another string the query uses
this value as filter.
Is all this possible ?