Recordset Loop Display without extra Spaces

CT Witter

MrExcel MVP
Joined
Jul 7, 2002
Messages
1,212
I'm using general recordset loop but am looking for some ideas on how to eliminate the final CR&LF.

Is there a good way to do this?

Below is the outline of my code

Code:
Do Until rst.EOF
      strOutput = strOutput & rst.Fields("Notes").Value & vbCrLf
      rst.MoveNext
      Loop

So for 2 Records I get
*BOF*
Record1
Record2
[BLANK]
*EOF*
Thanks,
CT [/code]
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Try losing the last character after the loop.

Code:
strOutput = Left(strOutput, Len(strOutput)-1)
 
Upvote 0

Forum statistics

Threads
1,221,864
Messages
6,162,497
Members
451,770
Latest member
tsalaki

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top