Connecting Tech Pros Worldwide Forums | Help | Site Map

Vb ms access loop

anoble1's Avatar
Newbie
 
Join Date: Jul 2008
Posts: 9
#1: Aug 18 '09
I'm trying to get a process which exports to a report running as a loop 6 times. The last working configuration was:
Expand|Select|Wrap|Line Numbers
  1. While Not records.EOF
  2.         For i = 1 To 4
So, I have 1,2,3,4 as you can see.. I just added 8 and 11
So I need a statement to add (example) For i = 1 To 4 and 8 and 11

I have also tried:
Expand|Select|Wrap|Line Numbers
  1. While Not records.EOF
  2.         For i = 1 To 4
  3.     Next i
  4.         For i = 8 To 8
  5.     Next i
  6.         For i = 11 To 11
That only grabbed "11" and nothing else.
Thanks

Expert
 
Join Date: Jul 2008
Location: Maryland
Posts: 1,175
#2: Aug 18 '09

re: Vb ms access loop


Here's one option, not optimized or anything.
Expand|Select|Wrap|Line Numbers
  1. Dim i As Integer
  2.  
  3.   i = 1
  4.   While i <= 11
  5.     '...
  6.     '...do stuff
  7.     '...
  8.     i = i + 1
  9.     if i = 5 then i = 8
  10.     if i = 9 then i = 11
  11. wend
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,218
#3: Aug 18 '09

re: Vb ms access loop


Quote:

Originally Posted by anoble1 View Post

I'm trying to get a process which exports to a report running as a loop 6 times. The last working configuration was:
While Not records.EOF
For i = 1 To 4
So, I have 1,2,3,4 as you can see.. I just added 8 and 11
So I need a statement to add (example) For i = 1 To 4 and 8 and 11

I have also tried:
While Not records.EOF
For i = 1 To 4
Next i
For i = 8 To 8
Next i
For i = 11 To 11
That only grabbed "11" and nothing else.
Thanks

Forgive me if I'm wrong, since I am having a little trouble trying to figure out exactly what you are trying to accomplish, but here goes:
Expand|Select|Wrap|Line Numbers
  1. Dim i As Integer
  2.  
  3. For i = 1 To 11
  4.   Select Case i
  5.     Case 1, 2, 3, 4, 8, 11
  6.       Debug.Print "Processing Item " & i
  7.     Case Else
  8.       'Ignore 5, 6, 7, 9, and 10
  9.   End Select
  10. Next
OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. Processing Item 1
  2. Processing Item 2
  3. Processing Item 3
  4. Processing Item 4
  5. Processing Item 8
  6. Processing Item 11
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,730
#4: Aug 18 '09

re: Vb ms access loop


As ADezii says, it's really not clear what you're after.

If using indenting in your explanatory code, it's really better to get the indents to match. Otherwise it's even more confusing than non-indented code.
Reply

Tags
access, loop, visual basic