Solved

loop without do error

Posted on 2004-10-21
277 Views
Last Modified: 2010-05-02
I am getting a loop without do error. Does anyone have a clue?  

 If Attempts <> 100 Then
        Do
            If Sheet3.Range("X") = x Then _
                y2 = Sheet3.Range("y2")
            Sheet3.Range("y2") = Sheet3.Range("try2")
            Attempts = Attempts + 1
            If Attempts = 100 Then
                MsgBox "*** Trapped Out ***" & Chr(10) & _
                    "v = " & v
                Exit Do
            End If
        Loop Until Sheet1.Range("X") < x
    End If
0
Question by:uTab
    22 Comments
     
    LVL 33

    Expert Comment

    by:hongjun
    your syntax is correct
    0
     
    LVL 10

    Expert Comment

    by:kiranghag
    i put it in vb here and its perefect without error!
    0
     
    LVL 33

    Expert Comment

    by:hongjun
    This is your question
    >>I am getting a loop without do error
    No errors mean good right? Isn't this what you wanted
    0
     

    Author Comment

    by:uTab
    But there is an error it is loop without do.
    0
     
    LVL 33

    Expert Comment

    by:hongjun
    sorry i don't quite get you.
    What do you mean?
    0
     

    Author Comment

    by:uTab
    The post prior to you yours telling me that this is what I wanted is not from me.  I do have an error
    0
     
    LVL 33

    Expert Comment

    by:hongjun
    what is the error?
    0
     
    LVL 33

    Expert Comment

    by:hongjun
    post the error message here.
    0
     
    LVL 3

    Expert Comment

    by:Noel_Castillo
    I also pasted the code in but i got no error.
    0
     

    Author Comment

    by:uTab
    The error is

    Compile error:
    Loop without Do

    The code is
     If Attempts <> 100 Then
            Do
                If Sheet3.Range("X") = x Then _
                    y2 = Sheet3.Range("y2")
                Sheet3.Range("y2") = Sheet3.Range("try2")
                Attempts = Attempts + 1
                If Attempts = 100 Then
                    MsgBox "*** Trapped Out ***" & Chr(10) & _
                        "v = " & v
                    Exit Do
                End If
            Loop Until Sheet1.Range("X") < x
        End If

    the section .range is highlighted
    0
     
    LVL 33

    Expert Comment

    by:hongjun
    do you have got Sheet1?

    hongjun
    0
     

    Author Comment

    by:uTab
    Yes
    0
     

    Author Comment

    by:uTab
    Could I email someone the entire code because I can not post it?
    0
     
    LVL 23

    Accepted Solution

    by:
    yes please.

    jyparask@yahoo.gr
    0
     
    LVL 11

    Expert Comment

    by:dbrckovi
    Try writing it without underscores "_"
    Like this:

        If Attempts <> 100 Then
            Do
                If Sheet3.Range("X") = x Then Y2 = Sheet3.Range("y2")
                Sheet3.Range("y2") = Sheet3.Range("try2")
                Attempts = Attempts + 1
                If Attempts = 100 Then
                    MsgBox "*** Trapped Out ***" & Chr(10) & "v = " & v
                    Exit Do
                End If
            Loop Until Sheet1.Range("X") < x
        End If
    0
     

    Author Comment

    by:uTab
    Nope, but it was worth a try
    0
     
    LVL 3

    Expert Comment

    by:Noel_Castillo
    can i also have a copy? noel_b_castillo@yahoo.com
    0
     
    LVL 23

    Expert Comment

    by:Ioannis Paraskevopoulos
           If Attempts2 <> 100 Then
                Do
                    If Sheet3.Range("cendPrincipal") = cPrincipal Then _       'Here you forgot to put the underscore
                        choldPay = Sheet3.Range("cpayment")
                        Sheet3.Range("cpayment") = Sheet3.Range("cNextPayTry")
                        Resolve_Payment
                        Attempts2 = Attempts2 + 1
                        If Attempts2 = 100 Then
                            MsgBox "*** Trapped Out ***" & Chr(10) & "HoldPay = " _
                                    & choldPay
                            Exit Do
                        End If
                    Loop Until Sheet3.Range("cendPrincipal") < cPrincipal
                End If
            End If




    try and see if it works now
    0
     
    LVL 11

    Expert Comment

    by:dbrckovi
    Hmm....

    Are you aware that you just broke one of the most strict rules here at EE.
    You have used e-mail to resolve a problem.

    See here: http://www.experts-exchange.com/help.jsp#hs8

    You have done exactly what they said is not allowed.
    0
     
    LVL 23

    Expert Comment

    by:Ioannis Paraskevopoulos
    You are right.

    I had read this when i joined experts-exchancge,but i had forgoten it.My fault
    0
     

    Author Comment

    by:uTab
    I am sorry I did not read the rule properly.
    0
     
    LVL 33

    Expert Comment

    by:hongjun
    @uTab

    Perhaps you can post the solution here so that future readers can learn something from it.

    hongjun
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Shellfire Box VPN + Lifetime Subscription

    The Shellfire Box easily connects all of your devices, even those that don't offer the possibility to establish a safe vpn connection. Access blocked content and surf safely, no matter where in the world you are located.

    Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    884 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now