470,563 Members | 1,946 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,563 developers. It's quick & easy.

Macro to Run multiple queries


I know virtually nothing about creating Macros in Access.

I would appreciate some help in creating a Macro or Macros that
automatically run(s) 14 Queries (three Make Table Queries, and 11
Append Queries) when the Database is first opened, and then again
anytime I invoke the Macro (somehow) after the database is already
open. The latter function is useful, because the queries must be rerun
every time data is added, deleted, or changed.

Actually, it is a little more complicated than that, because when six
of the queries run, two dialog boxes pop up that need to be closed
before the query will run. (I know why this happens, but I am not sure
I know how to fix it just now.) Before the 13th Append query runs, two
fields need to be added to the table that was created by the 7th Make
table query.

As hobbled and awkward as this database is, it does seem to work, and
I have put a lot of time and effort into it, so I would like to get
these last bugs out.

If anyone is interested in the application, here is a not so brief

I have created a complicated (and poorly written, I'm sure) database
that helps me keep track of my clients' active securities accounts on
a fiscal year basis. Unfortunately, the monthly statements provided by
the investment banker are on a calendar year, not a fiscal year basis,
they do not summarize purchases, and they do not provide cost basis
information. The investment counselor insists on using that particular
broker anyway, much to my dismay.

So that I have the information summarized when I need it at tax time,
my staff enters dozens of transactions for each account every month
into the database. I have designed queries, forms, and reports that
show the portfolio at cost at the end of each month, the purchases for
the month, the gains and losses for the month, and that reconcile the
cash account each month, summarizing interest, dividends, etc.

The database is continuous, including transactions for multiple years.
The reason for this is so data entry clerks won't have to enter the
beginning of the year portfolio by hand every year. Instead, I can
change the fiscal year criteria in the various queries to isolate the
current year transactions.

One of the features of the form I created to enter the data allows the
data entry clerk to enter multiple sales of partial lots of securities
in the same record as the original purchase (or purchases) so that the
remaining cost basis and shares held are calculated automatically.
Without this feature, data entry clerks would have to calculate the
cost of the securities sold and remaining basis themselves, an
error-prone procedure. The benefit of this automatic calculation comes
at a price, though. It becomes very difficult to isolate transactions
that occur in one fiscal year when the various sale dates in any one
record span more than one fiscal year. I have created six separate
sales fields within each record, such as SaleDate1, NoSharesSold1,
SalesPrice1, SaleDate2, NoSharesSold2, SalesPrice2, through SaleDate6,
etc. In most cases, six is enough.

I have devised a method to isolate the various dates within each
record that uses one Make Table and five or six Append Table Queries,
one for each of the Sales fields, 1 - 6. This way, the query only
needs to look at one date field at a time and can eliminate dates that
fall outside the fiscal year. The table thus created is limited to
fiscal year transactions. SaleDate 1 through 6 are combined in the
table as SaleDate, and the same for NoSharesSold and SalesPrice, but
the transactions are kept separate in the table, not combined.

I actually have two sets of six Make Table / Append to Table Queries
with six and seven total queries each (and a third make table query to
make a total of 14 queries). One set helps to calculate gains and
losses and the other helps to calculate the portfolio (summary and
detail) at cost.

Thanks in advance to anyone who might be willing to help me out.


Nov 13 '05 #1
0 8241

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

699 posts views Thread by mike420 | last post: by
5 posts views Thread by Comcast Newsgroups | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.