How To Restart A VBA Loop Counter

This is related to an interesting question I received from an individual, and this processing example may help someone.

Basically we are conducting a 10 day clinical study on a group of patients.

We want to store the results of the finding in a database and reset the study counter when a result comes back positive.

So if on “Day 1” the result is “NEG” then we proceed to “Day 2”, and if on “Day 2” the result is “NEG” then we proceed to “Day 3”, and so on for 10 days.

However, if on “Day 9”, the result is “POS”, then we must start the count over from “Day 1”.

This post is going to demonstrate 1 way of coding this.

Here is a shot of the database set up:

…and here is what the form looks like after the “Tally Results” button is clicked:

Notice that whenever the “POS” result is indicated, the test days need to start at 1 again.

Here is the code:

Watch how I do it:

Let me know if you have questions regarding this.


Free! Subscribe To Our YouTube Channel!

facebooktwittergoogle_plusredditpinterestlinkedinmailby feather
Tags: , , , , , , ,


Call Erik Now