[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.
Re: Creating a text file from a recordset
Welcome to the forums. :wave:
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.
Re: Creating a text file from a recordset
Thank you for your warm welcome! :D
I did try to write it straight to the text file originally, but I was having the same problem (the previous values were being overwritten).
I tried your idea of a multiline text box, but again it only displays the last value.
I'm getting a bit stuck here :confused:
Re: Creating a text file from a recordset
Try this
VB Code:
label1.Caption = label1.caption & rs.Fields("order_item").Value & vbCrLf
Re: Creating a text file from a recordset
Of course! I see now why it was overwriting what was being read originally :blush:
My text file is now working too! Many thanks! :thumb:
Re: Creating a text file from a recordset
Quote:
Originally Posted by beatlesgal25
Of course! I see now why it was overwriting what was being read originally :blush:
My text file is now working too! Many thanks! :thumb:
No problem. :thumb:
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. :)