Stop macro at end of query

A

Annette

This seems so simple, but because I'm VERY new at Access
macros, I can't figure it out! I have a macro that starts
at the first record in a query, calls another macro that
emails a report to the person in that record, and then
goes on to the next record. This works great UNTIL I get
to the last record and then the macro blows up. I'm sure
I need to add a condition and/or a repeat expression to
stop the macro at the last record of the query, but I
can't figure out the syntax. Can anyone help???? Thanks
soooo much!
 
A

Annette

From a form. The person opens the form that displays the
first record in the query. They click on a button that
opens the first of two macros. The first macro starts on
the first record of the query that the form is based upon
and then calls the second macro. The second macro opens a
report, emails the report, goes to the next record on the
form and closes. The first macro then restarts the
process on the next record. Problem is, when I get to the
last record, I get an ugly error and the form doesn't
close properly. Does that help? Thanks!
 
K

Ken Snell

Try using this as a condition expression for the macro that is calling the
second macro:

Forms!FormName.Form.Recordset.EOF = False

See if this stops the macro from calling the second macro when you reach the
end of the records.
 

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