max wrote:
Quote:
I have about 20 different querys but they all have some fields that use
the same expression. I would like to add criteria to those fields
without opening every query individually. Plus this criteria changes
frequently. Is there a macro that I could write where I can enter the
criteria once and the macro inserts it into all the different querys?
I'm using Access 2000. Thanks Max |
Are the queries used in forms? If so, why not use filters on the
queries. IOW, create your generic, show all queries and then filter the
query based on criteria.
I suppose with some exploration I could figure out a macro, but coding
is pretty straight forward. The main rules to recognize are:
Strings are encased in quotes
Dates are encased in pound signs
Numbers are not encased
LastName = 'Smith'
Today = #1/4/2004#
Amount = 1.01
Here is some sample code you can place in an event to filter a query.
It will select all sales records from today where the sales amount is
greater $100 in the Electronics dept.
Me.Filter = "[SalesDate] = #" & Date() & "# And [Dept] = 'Electronics'
And [SalesAmount] > 100"