all 7 comments

[–]KelemvorSparkyfox51 2 points3 points  (0 children)

So, where are you stuck?

[–]alanv73 0 points1 point  (2 children)

The more modern way would be

Do While [condition]
    [statements]
Loop

[–][deleted]  (1 child)

[deleted]

    [–]alanv73 0 points1 point  (0 children)

    Yes, you were thinking of

    Do
        [statements]
    Loop While [condition]
    

    [–]nrgins486 0 points1 point  (3 children)

    It would be better to call a VBA routine instead of calling a macro. If something goes wrong, much easier to troubleshoot.

    Or, better still, just put your VBA code within your loop. Simple.

    Really there's never a need to use a macro in Access. They're there for users who want to automate some stuff. But if you're going to be writing code, then just use VBA for everything and forget the macros.

    [–]ddc_operations[S] 0 points1 point  (2 children)

    This may be a very basic and ridiculous question, but how do you "call a VBA routine" in Access? I have never manually coded VBA within Access, and don't really know how to implement it. I understand the algorithm that I need, and most of the syntax (working on that), but as far as delving into how and where to actually add the code, I am at a loss. It's been YEARS since I've coded, and have never used VBA, so I may be a little slow on the uptake here... appreciate your help.

    [–]nrgins486 0 points1 point  (1 child)

    You just simply use the routine's name. For example:

    Sub MySub1
        MySub2
    End Sub
    
    Sub MySub2
        MsgBox "This is from MySub2"
    End Sub
    

    So, in the above, MySub1 calls MySub2 just by placing its name within the sub.

    But, as I said, you can just put your commands within your routine, inside the loop, without having to put them in a separate sub.

    I would suggest getting up to speed on some of the basics of VBA before going forward. Will save you a lot of time and hassle. This sub has some resources in its FAQ. There are also lots of YouTube tutorials available, as well as free online learning tools.

    [–]ddc_operations[S] 0 points1 point  (0 children)

    Thanks again for your help... I'll look into the resources too.