fornext doloop step

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » For/Next Do/Loop - Step Functions

For/Next Do/Loop - Step Functions

resolvedResolved · Low Priority · Version 2003

Ashley has attended:
Access VBA course

For/Next Do/Loop - Step Functions

Within a for/next loop i know you can 'step' through the loop using the code

For x to y step z
...
next

will step through a count loop only displaying multiples of z (if counting units for instance)

Is it possible to set up a similar step function using a do x/loop routine? I cant get it to accept the 'Step z' at the end of the Do.... line

Many Thanks

RE: For/Next Do/Loop - Step Functions

Hi Ashley

Thanks for your question.

Step values only work with count based loops. Conditional based loops require numeric variables to be increased explicitly.

An example would be as follows


Sub test()

a = 1
b = 10

Do While a < b


a = a + 2

Loop

End Sub

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Access tip:

Change case

To change case from upper or lower case, highlight the text area, hold down the Shift key and pres F3

View all Access hints and tips


Server loaded in 0.05 secs.