Nested Do While loops - keep getting "Loop without Do" error (1 Viewer)

atrium

Registered User.
Local time
Tomorrow, 00:28
Joined
May 13, 2014
Messages
348
I believe I should begetting a "Do While with out Loop" error????
I have two tables
The first one, rs1 is the outer loop. The file contains schedules that are the parent record to the second table of transactions, rs2. The major keys on the schedules table is DdSchedId and MatterId (Which is a higher parent)
The transactions represent the payments and the fees charged to a schedule. Each transaction has a DdScedTransId, DdShedId and MatterId to help link the two together.
The idea is that for each valid schedule there should be valid transactions that need to be totalled (Like trans types 13 = Direct debit, 50 = Direct Credit, 20 = Manual Payment) that need to be deducted from the Overall debt. Transactions 30 = Dis Hon fee, 35 = Penalty Fee, 60 = Transaction Fee, are needed to be added to the overall debt. The Interest, 40 = Interest, is recalculated on a daily basis to todays date (the date the update is actioned) and added to the total debt.

Some of the code I haven't included.

My problem is that I keep getting a "Loop without DO" error on the 2nd last line of code shown, The rest of the code in this Private Sub is commented
Any help will be most welcomed

I have attached the code
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 

Attachments

  • SchedUdate.txt
    11.2 KB · Views: 123

June7

AWF VIP
Local time
Today, 06:28
Joined
Mar 9, 2014
Messages
5,466
Missing

End If
Loop


just above NextSched:
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 09:28
Joined
Feb 28, 2001
Messages
27,142
I concur with June7. Just to explain the theory behind that...

When you create an If/Then/Else/End If type of structure, you create a program block. Things between the Then and the Else are in a block and things between Else and End If are in a different block. Just like a subroutine or function creates a code block between the Sub and End Sub or Function and End Function. The For/Next construct is another case. The Do While or Do Until and Loop statements ALSO form blocks.

Within those blocks, every flow structure must be self-contained. For instance, you CAN put a statement label inside an If-related block - but you cannot jump to that label from outside that block. (You can leave the block - but cannot enter.) You can jump out of a loop - but not into the middle of one.

When you get those pesky "Missing End If" or "Missing Loop" errors, it is usually because you omitted something that would have terminated the block and ran into another logic-flow element that had been started outside the current block. If you properly terminated the inner block, then the terminating statement for the outer block would have been OK.

Think of it as a type of parenthesis. If they are unbalanced, you are hosed.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 10:28
Joined
Feb 19, 2002
Messages
43,224
I don't understand why you are using an unbound form. I expected to see the code using VBA variables.
Queries could probably do all the summing with a lot less work.
 

Users who are viewing this thread

Top Bottom