Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Eliminate character returns in a report

Status
Not open for further replies.

trans5696

Technical User
Mar 10, 2004
1
US
HELP!! I'm sure there's a perfectly simple solution to my quandary...or at least I hope so.

I need for my report to loop in a continuous data string. So far, I have concatenated fields to form one report field for each record set.

It looks like this:

44520044646464646yyynv
45420043525264650yyynv
45320043525786450nnynv
46420044645878894nynnv

What I need is to also concatenate report fields themselves to eliminate the character return (It will wrap when exported to .txt format):

44520044646464646yyynv45420043525264650yyynv45320043525786450nnynv46420044645878894nynnv




 
I don't know if you really want to do a report here. I would do this with code. Here is something you could use. Just attach this code to a button on an unbound form, or however you want to activate it. Just in case you are not familliar with what I mean, use the toolbar to create a button, but click cancel on the wizard. Right-click on the button (in design mode) and choose build event and code builder. Paste this code(with appropriate bits renamed to fit your database) between the 'ButtonName_Click()' and the 'End Sub'.
Also, make sure you go into references and select DAO 3.6 Library.

------------------------------

Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("c:\NoLineBreaksHere.txt", True)





Dim ThisDbs As DAO.Database ''to have a recordset, you need a database.
Dim MyRecordset As DAO.Recordset

Dim strToTextFile As String


Set ThisDbs = CurrentDb
Set MyRecordset = ThisDbs.OpenRecordset("Table1")

Do Until MyRecordset.EOF = True
strToTextFile = ""
strToTextFile = strToTextFile & MyRecordset!Field1
strToTextFile = strToTextFile & MyRecordset!Field2
strToTextFile = strToTextFile & MyRecordset!Field3
MyRecordset.MoveNext
a.Write (strToTextFile)

Loop


a.Close
MyRecordset.Close
ThisDbs.Close


--------------------------------------
 
If you can pass the field to thsi function, then it wil replace carriage returns with spaces ... hope this helps.


Function Remove_Ch13(inpvalue As String) As String

'Find all char 13 in the string and replace it with "space"
Dim StrLen, i As Long
StrLen = Len(inpvalue)
i = 1

Do While i <= StrLen
If Asc(Mid(inpvalue, i, 1)) = 13 Then
inpvalue = Left(inpvalue, i - 1) & " " & Right(inpvalue, StrLen - i)
End If
i = i + 1
Loop

Remove_Ch13 = inpvalue

End Function

Cheers [pipe]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top