I need a function to loop a macro until a field reaches 0 (1 Viewer)

jconverse

New member
Local time
Today, 10:09
Joined
Apr 28, 2009
Messages
4
Thanks in advance!! I really have been out of VBA and Access for 5 years and have lost some of my edge. I need to loop a macro from a Function until a field in the Table [MakeRatio]![ASK] reaches 0. I can take care of the counting within the macro but I need to call a function from RUNCODE in a macro.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:09
Joined
Aug 30, 2003
Messages
36,118
I'm confused, you want to loop a macro from a function or call a function from a macro? You can use DLookup() to check the table value in your loop and exit when it's 0.
 

jconverse

New member
Local time
Today, 10:09
Joined
Apr 28, 2009
Messages
4
I'm confused, you want to loop a macro from a function or call a function from a macro? You can use DLookup() to check the table value in your loop and exit when it's 0.
Can you get me started on what it would look like?
 

plog

Banishment Pending
Local time
Today, 09:09
Joined
May 11, 2011
Messages
11,611
Code:
I can take care of the counting within the macro but I need to call a function from RUNCODE in a macro.

That's some Inception level processing you want to undertake. Why not just do the whole thing in VBA?

As pbaldy mentioned--you haven't given us any code and you haven't really specificied what part of the coding is tripping you up. So, give it a shot yourself (even if its just pseudo-code), if it doesn't work then post code and ask us about specific lines of codes or methods.
 

Isaac

Lifelong Learner
Local time
Today, 07:09
Joined
Mar 14, 2017
Messages
8,738
Did you mean to say that you want to call this code inside of a SUB, rather than inside of a function? It would be kind of odd to call code from within a function, clearly not that it could never happen but it would be less common
 

plog

Banishment Pending
Local time
Today, 09:09
Joined
May 11, 2011
Messages
11,611
A Sub is just a Function that doesn't return anything. Don't know why a sub would be more/less likely to do anything a function does.
 

plog

Banishment Pending
Local time
Today, 09:09
Joined
May 11, 2011
Messages
11,611
I was wrong, there's another difference--you cannot call a Sub from a macro, but you can call a Function from a macro. But that just underscores that he definitely meant Function.
 

Isaac

Lifelong Learner
Local time
Today, 07:09
Joined
Mar 14, 2017
Messages
8,738
I definitely think it would be less common to call other code from within a function. Yes I'm quite aware of what a function and sub are. Anyway, we can wait till he clarifies
 

Users who are viewing this thread

Top Bottom