Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

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

ResolvedVersion 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:

Using the Quick Access Toolbar in Access 2010

The Quick Access Toolbar is included in virtually every Office product, including Outlook 2010, Word 2010, Excel 2010, and PowerPoint 2010.

You will find the Quick Access Toolbar in the top-left side of the window. To begin, click the Customize button (it's the little black arrow at the end of the toolbar).

Simply click the commands you want to include.

Virtually any command can be added to the Quick Access Toolbar. Click the More Commands option and a new window will open from where you can browse the commands including those not on the ribbon.

View all Access hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.