Stop macro at end of query

  • Thread starter Thread starter Annette
  • Start date Start date
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!
 
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!
 
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.
 
Back
Top