People,
this is a wired one for me. I am executing my module and I am getting a compile error - "Loop without a Do" even though I do have a "Do".

Below is my module:

ii = 5
    ii = ii + 1

    Do Until M.qBW.EOF
        xlWksht.Cells(ii, 1).Value = M.qBW![Req No]
        xlWksht.Cells(ii, 2).Value = M.qBW![Description]
        xlWksht.Cells(ii, 3).Value = M.qBW![ClientName] & Chr(10) & M.qBW![Status]
        xlWksht.Cells(ii, 4).Value = M.qBW![P L] & Chr(10) & M.qBW![TotalProg1Hrs]

        rsinPers.MoveFirst
        Do Until rsinPers.EOF
           If rsinPers![Name] = M.qBW![Personnel2] Then
           xlWksht.Cells(ii, 5).Value = rsinPers![Initials] & Chr(10) & M.qBW![TotalProg2Hrs]
           rsinPers.MoveNext
        Loop

        rsinPers.MoveFirst
        Do Until rsinPers.EOF
           If rsinPers![Name] = M.qBW![Personnel3] Then xlWksht.Cells(ii, 6).Value = rsinPers![Initials] & Chr(10) & M.qBW![TotalProg3Hrs]
           rsinPers.MoveNext
        Loop
        
          rsinPers.MoveFirst
        Do Until rsinPers.EOF
           If rsinPers![Name] = M.qBW![Personnel4] Then xlWksht.Cells(ii, 7).Value = rsinPers![Initials] & Chr(10) & M.qBW![TotalProg4Hrs]
           rsinPers.MoveNext
        Loop
        
        rsinPers.MoveFirst
        Do Until rsinPers.EOF
           If rsinPers![Name] = M.qBW![Personnel5] Then xlWksht.Cells(ii, 8).Value = rsinPers![Initials] & Chr(10) & M.qBW![TotalProg5Hrs]
           rsinPers.MoveNext
        Loop
        
        rsinPers.MoveFirst
        Do Until rsinPers.EOF
           If rsinPers![Name] = M.qBW![Personnel6] Then xlWksht.Cells(ii, 9).Value = rsinPers![Initials] & Chr(10) & M.qBW![TotalProg6Hr]
           rsinPers.MoveNext
        Loop
        
        xlWksht.Cells(ii, 10).Value = "-" & Chr(10) & M.qBW.Fields("Per Hrs")
        xlWksht.Cells(ii, 11).Value = M.qBW.Fields("EstimatedTotalHours") & Chr(10) & M.qBW.Fields("Tot Hrs")
        xlWksht.Cells(ii, 12).Value = M.qBW![EstimatedStartDate] & Chr(10) & M.qBW![Start Date]
        xlWksht.Cells(ii, 13).Value = M.qBW![EstimatedEndDate] & Chr(10) & M.qBW![End  Date]
        xlWksht.Cells(ii, 14).Value = "Comments:" & Chr(10) & "'" & M.qBW![Comments]
    Loop

Thanks
tgifgemini

Hi,

Your problem is in line 10 where you have seperated the If Then statment from their result without using End If. Just get line 11 to be directly after Then in line 10 (without going down to a new line) and it will work, I mean:
.... M.qBW![Personnel2] Then xlWksht.Cells(ii, 5).Va ...

I hope I was able to help you.

Hi,

Change in in the first Inner Do Loop:

Do Until rsinPers.EOF
           If rsinPers![Name] = M.qBW![Personnel2] Then xlWksht.Cells(ii, 5).Value = rsinPers![Initials] & Chr(10) & M.qBW![TotalProg2Hrs]
           rsinPers.MoveNext
        Loop

REgards
Veena

Thanks guys.
Mission accomplished. I wasn't aware that I was missing "End if".
Thanks again.
tgifgemini.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.