conditional while loop

cpampas

Registered User.
Local time
Today, 14:38
Joined
Jul 23, 2012
Messages
221
Is there a way to set the condtions for a loop while, like this :

if a = - 1 then
ate= me.valor
end if

in case the variable (ate) is not null the first line of the line would be ---> Do While !rabat < ate
and in case (ate) is null the first line would be -----> Do While Not .EOF
 
I think we need to see the whole code you are trying to use.
You can "nest" conditions and loops but from your description, I can't guess at the correct structure.

Where and how are you setting the recordset?
You can use an If Then Else construct to switch between two loops.
 
I was hoping that I there was another way rather than if Then, to switch between loops that are equal, except for the first line


Code:
Forms!frmMagicCont!frmB.Form.OrderBy = "[rabat]"
    Forms!frmMagicCont!frmB.Form.OrderByOn = True
    Me.Recalc
    
   Set rstV = Forms!frmMagicCont!frmB.Form.RecordsetClone
   rstV.MoveLast: rstV.MoveFirst
  
            
        Dim ate As Double

        If [Forms]![frmMagicCont]![Procura de Documentos].[Form]![tira] = -1 Then
               ate = [Forms]![frmMagicCont]![Procura de Documentos].[Form]![tiraP]
        End If

        with rstV
             Do While !rabat < ate ' here I would like to goto until the end of the recordset in case ate is null
     
                    If Not !vendido = -1 Then
                            If URLExists(!linkMaq) = False Then
                                 .Edit
                                         !vendido = -1
                                .Update
                           End If
                   End If
          .MoveNext
        Loop
            .Requery
        End With
 
Do While !rabat < ate ' here I would like to goto until the end of the recordset in case ate is null
it cannot go null because you declare it as Double.
when you did not assign value to it, it's value is 0.
 
Simply set ate to either the number or the number of records + 1? Before your loop

If ate = 0 Then ate = rstV.RecordCount + 1
 
Not sure this is the right way , but it worked for me
Thanks for your help


Code:
Do While not .EOF

          If !rabat > ate Then Exit Do

                    If Not !vendido = -1 Then
                            If URLExists(!linkMaq) = False Then
                                 .Edit
                                         !vendido = -1
                                .Update
                           End If
                   End If
          .MoveNext
        Loop
 

Users who are viewing this thread

Back
Top Bottom