Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Replacing commas with line return in report

Author  Topic 

kaus
Posting Yak Master

179 Posts

Posted - 2003-04-02 : 19:53:52
I have a report that reads data from sql server table. There is a field that has comma separated values, does anybody know how or if the commas could be replaced with line returns in the access report so that

6540a,6540b
would read
6540a
6540b

in the report ??

Thanks

Pete

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2003-04-02 : 22:29:14
Pete,

Here's how I just did it:

1. Drop a text box (txt1) on the report and link it to the datasource item.
2. Create another unlinked text box (txt2)
3. Create some code in the report's Detail_Format that looks like this:
 Me.txt2 = Replace(Me.txt2, ",", vbCrLf)

4. Set the txt2's property of CanGrow to True
5. Hide the txt1 control.
6. Run it.

I started off trying to insert the Replace code in the text box's control source, but all I got was errors when I tried a preview.

Tim


Go to Top of Page

kaus
Posting Yak Master

179 Posts

Posted - 2003-04-03 : 13:38:49
Clever -- I'll give it a go -- thanks

Pete

Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-04-03 : 14:02:52
Kaus --

there are even easier, more direct ways to go.

1. In your query, just use the replace function on the field and put that in your report.


or

2. in the report, just set the control source of a text box to:

=replace( .... blah blah blah ... )


No need for VB or hidden text boxes or any of that. I always say the most direct and simpliest solution is usually the best.

If you haven't played with using functions and/or expressions in text boxes on reports on in queries, you are really missing out on some of the most powerful features of Access.

Hope this helps!

- Jeff
Go to Top of Page
   

- Advertisement -