Reproducing RunMacro action in code

Maybe:

Not IsNull([kplus])

???
 
I have just been trying this While and Wend and Call abc on the basis [kplus] Is Not Null

abc is the code version of one of the macros that is run by RunMacro
 
This

While ("[kplus] Is Not Null")

Call abc

Wend

Makes it run down the records and doing the right thing but it does not stop. It should be through to China by now:D

Without the brackets I get deBug and typing.
 
mike,
the expression

DoCmd.RunMacro "Macro21", , "[kplus] Is Not Null"

should keep running until [kplus] is null is this correct?

rick
 
mike,
can you post a zip file of your db for us to look at so we can get a feel for what you are trying to do?

Rick
 
mike,
can you post a zip file of your db for us to look at so we can get a feel for what you are trying to do?

Rick

Will do.

But this worked, although obviously limited

While Forms!Table5!kplus > 0

Call abc

Wend

I filled [kplus] with a 1

I think the problem with [kplus] Is Not Null is that is based on an expression used for RunMacro but when RunMacro is in another macro. It does not make it run, it will run anyway but stops it.

On the other hand Forms!Table5!kplus > 0 makes it run.
 
Rick,

There you go.

Open form Table5. It should have 50 in the first record. make sure the 50 is black as the action is Copy. Should be balck when you open.

Click on the label.

abc() is in Module 1 and being called as in

While Forms!Table5!kplus > 0

Call abc

Wend

abc was a macro changed to code.

I had better check the macro that was doing the RunMacro as it had othe stuff before the RunMacro action.
 
With While/Wend and variations of Until/Loop etc I can get it to stop where I can use = < > <> and for a number or word or a letter

BUT I can't stop it for a Null record and that just happens to be the one I need most:D

Help!!!:D
 
I have been able to stop the loop when a Null record is reached by

While [kplus] <> 1.0101010101

Call abc

Wend

As well as

Do

Call abc

Loop While [kplus] <> 1.0101010101

"While" partly does the first Null record but stops. "Do" completes the Null record and partly does the next Nul record. But I can fix the "While"

I could find nothing on the Google that would solve the Null condition problem. However, from trying everything I could it was appearing as if Null was not being recognised or whatever. Thus the condition field where records are not null has no record with 1.01010101 and so the loop continues but I think it is stoping at a null record because it does not know what to do.

<>abcd etc also works, anything works as long as the (<> whatever) does not equal the value of a record in the condition field. However, if say <>15 is used and a record has 15 then the While/Wend stops at that record as opposed to going to the next record when <>15 does not match any record and a null record stops it.

I am sure there is a better way than what I have done to match Is Not Null in a macro to stop the RunMacro action.

The function abc() being called is the macro converted to code that was run by RunMacro
 
I got the last one I needed which was to run the function a specified number of times

Dim x As Integer

For x = 1 To 1000

Call abc

Next x

So I can replicate RunMacro for everything:D but the one to stop when reaching a null record on a condition field is messy, but it works

Thanks to all for your guidance
 
One I forgot

Dim x As Integer

For x = [Text6] To [Text8]

Call abc

Next x


But is there some way to do it with just the number required.

In the macro the counterpart of the above is just the number or =[Text6]
 

Users who are viewing this thread

Back
Top Bottom