Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Sep 2001
    Location
    Stuck at work..., Missouri, USA
    Posts
    248
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Go to next record without processing current recor (VBA)

    Consider the following:
    <pre>While Not (rst.EOF)
    '1 do somthing here

    '2 do something else here

    If rst.Field = "X" Then
    'go to the next record without doing any of the next steps
    End If

    '3 do a step here

    '4 do another step here

    rst.next
    Wend</pre>



    How can I go to the next record without having steps 3 & 4 executed when the "IF" condition is met?

    Thanks!
    <font face="Comic Sans MS">Morgan Erickson</font face=comic>
    morgan.erickson@sprint.com
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18>-From <img src=/S/flags/Colorado.gif border=0 alt=Colorado width=30 height=18> but living in <img src=/S/flags/Missouri.gif border=0 alt=Missouri width=30 height=18>...and working in Kansas.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Go to next record without processing current recor (VBA)

    Do While Not rst.EOF
    '1 something
    '2 something else
    If Not (rst.Field = "X") Then
    '3 do a step
    '4 do another step
    End If
    rst.MoveNext
    Loop

  3. #3
    3 Star Lounger
    Join Date
    Sep 2001
    Location
    Stuck at work..., Missouri, USA
    Posts
    248
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Go to next record without processing current recor (VBA)

    While that would work, my example was an overly simplistic one.

    I was hoping for something along the lines of Java's Break or Continue.

    It could be possible to skip to the next record after any of the steps, and there are not only 4 in the real program.

    GOTO would work, but I'd be the black sheep of the VBA world, right? :-)
    <font face="Comic Sans MS">Morgan Erickson</font face=comic>
    morgan.erickson@sprint.com
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18>-From <img src=/S/flags/Colorado.gif border=0 alt=Colorado width=30 height=18> but living in <img src=/S/flags/Missouri.gif border=0 alt=Missouri width=30 height=18>...and working in Kansas.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Go to next record without processing current recor (VBA)

    No, VBA only has an Exit Do, but that jumps out of the entire Do ... Loop construct.

  5. #5
    3 Star Lounger
    Join Date
    Sep 2001
    Location
    Stuck at work..., Missouri, USA
    Posts
    248
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Go to next record without processing current recor (VBA)

    Yeah, I was afraid of that...

    Had to try, though.
    <font face="Comic Sans MS">Morgan Erickson</font face=comic>
    morgan.erickson@sprint.com
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18>-From <img src=/S/flags/Colorado.gif border=0 alt=Colorado width=30 height=18> but living in <img src=/S/flags/Missouri.gif border=0 alt=Missouri width=30 height=18>...and working in Kansas.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •