Stop macro by the number of cycled records less one

G

Guest

The RUNMACRO number of repeats is always a number and can never be a
function. I have found a way to repeat the related MACRO by the cycled number
of filtered records, but once it reaches the final record I always have an
error and a halt macro question. Is there any way to repeat a macro by the
number of records being cycled less one?
 
T

tina

The RUNMACRO number of repeats is always a number and can never be a
function.

the RepeatCount argument can be an *expression* that uses a function. if you
have a function that returns the exact count you need, try

=FunctionName()

in the argument, rather than just

FunctionName()

hth
 
G

Guest

What in your opinion would be the function to count all cycled records of a
form except the last?
 
G

Guest

Dear Tina, perhaps you can help in a different way. The Runmacro , has the
following repeat action condition :[dataid]<>Max([dataid]) , so that it keeps
testing untill we get the maximum dataid. The action is repeat is actually
GOTO next. It is the GOTO next which need to be stopped once you are at the
MAXID, and it doesnt. Any ideas of a condion for this last action to stop
once the last record is reached?
 
T

tina

The RUNMACRO number of repeats is always a number and can never be a
function. I have found a way to repeat the related MACRO by the cycled number
of filtered records

your statements in initial post left me with the impression that 1) you know
how to get the number you need, and 2) it involves using a function. so my
answer was geared toward helping you use the function to set the number of
repeats.
What in your opinion would be the function to count all cycled records of a
form except the last?

before i can answer that, you'll need to explain what you mean by "cycled"
records.

hth
 
T

tina

are the records in the form sorted by the DataID field? if so, then the
highest value will be in the last record in the form. how about just using
the GoToRecord action with the Record argument set to Last, with no need to
use a RunMacro repeating action.

if that won't work, then you need to explain in some detail *what* you're
trying to accomplish (not *how* you've been trying to do it), and what your
setup is.

hth


diana said:
Dear Tina, perhaps you can help in a different way. The Runmacro , has the
following repeat action condition :[dataid]<>Max([dataid]) , so that it keeps
testing untill we get the maximum dataid. The action is repeat is actually
GOTO next. It is the GOTO next which need to be stopped once you are at the
MAXID, and it doesnt. Any ideas of a condion for this last action to stop
once the last record is reached?
diana said:
The RUNMACRO number of repeats is always a number and can never be a
function. I have found a way to repeat the related MACRO by the cycled number
of filtered records, but once it reaches the final record I always have an
error and a halt macro question. Is there any way to repeat a macro by the
number of records being cycled less one?
 
G

Guest

Dear Mam,
1- Cycled records are number of records filtered each time. They vary by
number each time i open the form.
2- I followed your first suggestion and tried to use the =Count() function
for the REPEAT COUNT, but the system refuses it.
3-Regarding the REPEAT EXPRESSION, i resorted to dataid versus maxid because
most of the times, not always, the maxid is the last record. What I actually
need is the number of records, regardless of the dataid.
4- I am setting the value of a field on each row from a calculated balance.
I therefore use GOTO NEXT before reaching the Last record.
5- I tried to STOP ALL MACROS before GOTO NEXT using the condition
:[dataid]=Max([dataid]) but it will not work. I also tried the condition
[totalrecords]=Form!Formname.[cycle], where totalrecords is a count field in
the form.
SUMMARY: I am executing a set value action for different filtered records on
each row, but once I reach the last record the action does not stop , the
STOPALLMACROS is overridden by GOTO NEXT.
Appreciate your suggestions.
tina said:
are the records in the form sorted by the DataID field? if so, then the
highest value will be in the last record in the form. how about just using
the GoToRecord action with the Record argument set to Last, with no need to
use a RunMacro repeating action.

if that won't work, then you need to explain in some detail *what* you're
trying to accomplish (not *how* you've been trying to do it), and what your
setup is.

hth


diana said:
Dear Tina, perhaps you can help in a different way. The Runmacro , has the
following repeat action condition :[dataid]<>Max([dataid]) , so that it keeps
testing untill we get the maximum dataid. The action is repeat is actually
GOTO next. It is the GOTO next which need to be stopped once you are at the
MAXID, and it doesnt. Any ideas of a condion for this last action to stop
once the last record is reached?
diana said:
The RUNMACRO number of repeats is always a number and can never be a
function. I have found a way to repeat the related MACRO by the cycled number
of filtered records, but once it reaches the final record I always have an
error and a halt macro question. Is there any way to repeat a macro by the
number of records being cycled less one?
 
T

tina

try the following public function (save it in a standard module, not in the
form's module), as

Public Function isCount() As Long

isCount = Screen.ActiveForm.RecordsetClone.RecordCount

End Function

in the macro RepeatCount argument, use the following expression, as

=isCount()

if you need to adjust the number of repeats, do the math in the expression.
for example, to get one less repeat, use

=isCount()-1

make sure you run the macro from the form that has the records to be
counted, *not* from another form.

hth


diana said:
1- Cycled records are number of records filtered each time. They vary by
number each time i open the form.
2- I followed your first suggestion and tried to use the =Count() function
for the REPEAT COUNT, but the system refuses it.
3-Regarding the REPEAT EXPRESSION, i resorted to dataid versus maxid because
most of the times, not always, the maxid is the last record. What I actually
need is the number of records, regardless of the dataid.
4- I am setting the value of a field on each row from a calculated balance.
I therefore use GOTO NEXT before reaching the Last record.
5- I tried to STOP ALL MACROS before GOTO NEXT using the condition
:[dataid]=Max([dataid]) but it will not work. I also tried the condition
[totalrecords]=Form!Formname.[cycle], where totalrecords is a count field in
the form.
SUMMARY: I am executing a set value action for different filtered records on
each row, but once I reach the last record the action does not stop , the
STOPALLMACROS is overridden by GOTO NEXT.
Appreciate your suggestions.
tina said:
are the records in the form sorted by the DataID field? if so, then the
highest value will be in the last record in the form. how about just using
the GoToRecord action with the Record argument set to Last, with no need to
use a RunMacro repeating action.

if that won't work, then you need to explain in some detail *what* you're
trying to accomplish (not *how* you've been trying to do it), and what your
setup is.

hth


diana said:
Dear Tina, perhaps you can help in a different way. The Runmacro , has the
following repeat action condition :[dataid]<>Max([dataid]) , so that
it
keeps
testing untill we get the maximum dataid. The action is repeat is actually
GOTO next. It is the GOTO next which need to be stopped once you are
at
the
MAXID, and it doesnt. Any ideas of a condion for this last action to stop
once the last record is reached?
:

The RUNMACRO number of repeats is always a number and can never be a
function. I have found a way to repeat the related MACRO by the
cycled
number
of filtered records, but once it reaches the final record I always
have
an
error and a halt macro question. Is there any way to repeat a macro
by
the
number of records being cycled less one?
 
G

Guest

This works like magic. A million thanks.

tina said:
try the following public function (save it in a standard module, not in the
form's module), as

Public Function isCount() As Long

isCount = Screen.ActiveForm.RecordsetClone.RecordCount

End Function

in the macro RepeatCount argument, use the following expression, as

=isCount()

if you need to adjust the number of repeats, do the math in the expression.
for example, to get one less repeat, use

=isCount()-1

make sure you run the macro from the form that has the records to be
counted, *not* from another form.

hth


diana said:
1- Cycled records are number of records filtered each time. They vary by
number each time i open the form.
2- I followed your first suggestion and tried to use the =Count() function
for the REPEAT COUNT, but the system refuses it.
3-Regarding the REPEAT EXPRESSION, i resorted to dataid versus maxid because
most of the times, not always, the maxid is the last record. What I actually
need is the number of records, regardless of the dataid.
4- I am setting the value of a field on each row from a calculated balance.
I therefore use GOTO NEXT before reaching the Last record.
5- I tried to STOP ALL MACROS before GOTO NEXT using the condition
:[dataid]=Max([dataid]) but it will not work. I also tried the condition
[totalrecords]=Form!Formname.[cycle], where totalrecords is a count field in
the form.
SUMMARY: I am executing a set value action for different filtered records on
each row, but once I reach the last record the action does not stop , the
STOPALLMACROS is overridden by GOTO NEXT.
Appreciate your suggestions.
tina said:
are the records in the form sorted by the DataID field? if so, then the
highest value will be in the last record in the form. how about just using
the GoToRecord action with the Record argument set to Last, with no need to
use a RunMacro repeating action.

if that won't work, then you need to explain in some detail *what* you're
trying to accomplish (not *how* you've been trying to do it), and what your
setup is.

hth


Dear Tina, perhaps you can help in a different way. The Runmacro , has the
following repeat action condition :[dataid]<>Max([dataid]) , so that it
keeps
testing untill we get the maximum dataid. The action is repeat is actually
GOTO next. It is the GOTO next which need to be stopped once you are at
the
MAXID, and it doesnt. Any ideas of a condion for this last action to
stop
once the last record is reached?
:

The RUNMACRO number of repeats is always a number and can never be a
function. I have found a way to repeat the related MACRO by the cycled
number
of filtered records, but once it reaches the final record I always have
an
error and a halt macro question. Is there any way to repeat a macro by
the
number of records being cycled less one?
 
T

tina

you're welcome :)


diana said:
This works like magic. A million thanks.

tina said:
try the following public function (save it in a standard module, not in the
form's module), as

Public Function isCount() As Long

isCount = Screen.ActiveForm.RecordsetClone.RecordCount

End Function

in the macro RepeatCount argument, use the following expression, as

=isCount()

if you need to adjust the number of repeats, do the math in the expression.
for example, to get one less repeat, use

=isCount()-1

make sure you run the macro from the form that has the records to be
counted, *not* from another form.

hth


diana said:
1- Cycled records are number of records filtered each time. They vary by
number each time i open the form.
2- I followed your first suggestion and tried to use the =Count() function
for the REPEAT COUNT, but the system refuses it.
3-Regarding the REPEAT EXPRESSION, i resorted to dataid versus maxid because
most of the times, not always, the maxid is the last record. What I actually
need is the number of records, regardless of the dataid.
4- I am setting the value of a field on each row from a calculated balance.
I therefore use GOTO NEXT before reaching the Last record.
5- I tried to STOP ALL MACROS before GOTO NEXT using the condition
:[dataid]=Max([dataid]) but it will not work. I also tried the condition
[totalrecords]=Form!Formname.[cycle], where totalrecords is a count
field
in
the form.
SUMMARY: I am executing a set value action for different filtered
records
on
each row, but once I reach the last record the action does not stop , the
STOPALLMACROS is overridden by GOTO NEXT.
Appreciate your suggestions.
:

are the records in the form sorted by the DataID field? if so, then the
highest value will be in the last record in the form. how about just using
the GoToRecord action with the Record argument set to Last, with no
need
to
use a RunMacro repeating action.

if that won't work, then you need to explain in some detail *what* you're
trying to accomplish (not *how* you've been trying to do it), and
what
your
setup is.

hth


Dear Tina, perhaps you can help in a different way. The Runmacro ,
has
the
following repeat action condition :[dataid]<>Max([dataid]) , so
that
it
keeps
testing untill we get the maximum dataid. The action is repeat is actually
GOTO next. It is the GOTO next which need to be stopped once you
are
at
the
MAXID, and it doesnt. Any ideas of a condion for this last action to
stop
once the last record is reached?
:

The RUNMACRO number of repeats is always a number and can never be a
function. I have found a way to repeat the related MACRO by the cycled
number
of filtered records, but once it reaches the final record I
always
have
an
error and a halt macro question. Is there any way to repeat a
macro
by
the
number of records being cycled less one?
 

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