Solved

Help with loop

Posted on 1998-08-19
4
130 Views
Last Modified: 2010-04-30
VB5  f= MSFlexgrid, rs = DAO recordset
Following loop is not looping it returns only last record in
the recordset and places it in the grid.
///
Do Until rs.EOF
str = ""
For i = 0 To rs.Fields.Count - 1
str = str & rs.Fields(i).Value & vbTab
Next i
f.AddItem str
rs.MoveNext
Loop
///
anu help appreciated
0
Comment
Question by:mativare
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 4

Expert Comment

by:mcix
ID: 1429954
Code looks OK...


1. Set a break point on str = ""
2. Insert a Debug.Print before Next i
3. Run (F5)
4. Step through the code using the F8 Key
5. After executing the Debug.Print, check the intermediate window CTRL G

You should see the value of str in that window.
You are checking to make sure your record set is there...

0
 
LVL 4

Expert Comment

by:mcix
ID: 1429955
Code looks OK...


1. Set a break point on str = ""
2. Insert a Debug.Print before Next i
3. Run (F5)
4. Step through the code using the F8 Key
5. After executing the Debug.Print, check the intermediate window CTRL G

You should see the value of str in that window.
You are checking to make sure your record set is there...

0
 
LVL 2

Expert Comment

by:richtsteig
ID: 1429956
I hope you just forgot to post the rs.movefirst?!
0
 
LVL 1

Accepted Solution

by:
blwatkins earned 50 total points
ID: 1429957
Place a RS.MoveLast and a RS.MoveFirst before your "Do Until" statement.
this will but you at the begining of your recordset.

Then do a little test to see how many records are in your recordset, to make sure you have more than one record.
Right after the above command put this:
  Msgbox ("Number of Records: " & rs.recordcount)

This will show you the number of records in your recordset.

I have the feeling you only have one record in your recordset.

The rest of your code looks fine.


0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

756 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