|
-
Feb 20th, 2006, 01:29 PM
#1
Thread Starter
Junior Member
[RESOLVED] Creating a text file from a recordset
Hi there
I have a table in Access 2002 and I need to create a text file from a recordset in VB6. I have set up the connection (and so on) but when I try to read the values from the recordset into a label, only the last value is displayed - as if the other values are being overwritten.
I know the values are there as I have tried using a msgbox and this displays them fine.
Below is the snippet of code I am using:
VB Code:
Do While Not rs.EOF
label1.Caption = rs.Fields("order_item").Value & vbCrLf
rs.MoveNext
Loop
Can anyone help me please? This might be a really simple question, but I'm not the best of programmers.
Many thanks!
Emma.
-
Feb 20th, 2006, 01:39 PM
#2
Re: Creating a text file from a recordset
Welcome to the forums. 
Love your username! 
If you want to write your recordset to a text file why are you trying to display in in a label? Why not just write it to the file?
Also, if need to display the recordset on a screen, then rather than a label, I would use a multiline textbox.
-
Feb 20th, 2006, 02:09 PM
#3
Thread Starter
Junior Member
-
Feb 20th, 2006, 02:10 PM
#4
Re: Creating a text file from a recordset
Try this
VB Code:
label1.Caption = label1.caption & rs.Fields("order_item").Value & vbCrLf
-
Feb 20th, 2006, 02:15 PM
#5
Thread Starter
Junior Member
-
Feb 20th, 2006, 02:16 PM
#6
Re: Creating a text file from a recordset
 Originally Posted by beatlesgal25
Of course! I see now why it was overwriting what was being read originally
My text file is now working too! Many thanks! 
No problem. 
If this is resolved, please pull down the Thread Tools menu and click the Mark Thread Resolved button. That will let everyone know that you have your answer.
Thank you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|