473,698 Members | 2,616 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Removing carriage returns from a field

1 New Member
Hello,

I'm using InfoPath to write data to a accessvdatabase . Once the form has been submitted a VB script runs to create a text file to input to another application. Some of the fields contain carriage returns and I need these replaced by /n.

[script]
Sub LogChangesV2()
Dim qdf As DAO.QueryDef
Dim db As DAO.Database

Dim rst As DAO.Recordset
Rem This set the variable rst to the record set for this macro

Set rst = CurrentDb.OpenR ecordset("Chang esReadyToLog")
Rem this sets the record set to be the ChangesReadyToL og query

Set fs = CreateObject("S cripting.FileSy stemObject")
Set TextFile = fs.CreateTextFi le("c:\ChangeRe quests\Changes. IMP", True)
Rem This creates the .txt file

Do Until rst.EOF = True

TextFile.writel ine ("@*@EVENTTYPE@ *@:R")
TextFile.writel ine ("@*@AFFECTED@* @:" & rst!AffectedUse r)
TextFile.writel ine ("@*@ITEM@*@ :" & rst!Item)
TextFile.writel ine ("@*@CATEGORY@* @:NORMAL CHANGE")
TextFile.writel ine ("@*@PRIORITY@* @:RFC")
TextFile.writel ine ("@*@SERIOUS@*@ :RFC")
TextFile.writel ine ("@*@REQUIREDBY DATE@*@:" & rst!RequiredBy)
TextFile.writel ine ("@*@SCHEDULEDD ATE@*@:" & rst!ScheduledDa te)
TextFile.writel ine ("@*@ENDDATE@*@ :" & rst!EndDate)
TextFile.writel ine ("@*@USER1CHAR1 @*@:" & rst!Just)
TextFile.writel ine ("@*@USER1CHAR2 @*@:" & rst!Risk)
TextFile.writel ine ("@*@USER1CHAR3 @*@:" & rst!CommPlan)
TextFile.writel ine ("@*@USER2CHAR1 @*@:" & rst!Implementat ion)
TextFile.writel ine ("@*@USER2CHAR2 @*@:" & rst!TestPlan)
TextFile.writel ine ("@*@USER2CHAR3 @*@:" & rst!BackOutPlan )
TextFile.writel ine ("@*@MAINEVENT@ *@:" & rst!AssystRef)
TextFile.writel ine (rst!Desc)
TextFile.writel ine ("|END OF INCIDENT|")
TextFile.writel ine ("")
Rem the code above creates the txt file structure

rst.Edit
rst!Logged = True
rst!ReadyToLog = False
rst.Update
Rem this sets the Logged field to True and the ReadyToLog field to false this removes it from the query

rst.MoveNext
Loop

End Sub
What I need to do is search the rst!Implementat ion field and replace the carriage returns with a /n before write the line to the changes.imp text file.

Any ideas would be great.
Thanks
Chris
Mar 27 '07 #1
1 2332
Denburt
1,356 Recognized Expert Top Contributor
Replace(rst!Imp lementation ,vbcrlf,"/n")
Mar 27 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
7315
by: Les Juby | last post by:
Can someone please help with a suggestion as to how I can keep the formatting (carriage returns) that the user enters into a memo field and then display that later. I figured I might be able to use: 'replace carriage returns with BRs comment=Replace(comment, chr(13), "<br>") but obviously net.! The <pre> tag doesn't sem to help either as the embedded return is
3
2030
by: Dave | last post by:
I need to strip out carriage returns from a memo field. Basically, one of the commercial databases we have uses a memo field for the address, and what I'd like to do is get rid of the carriage returns so I can have the address on a single line (possibly separated by commas) in a different database. Any suggestions gratefully received. Apologies if you replied to this earlier, I think my ISP must have dropped the newsgroup a week or two...
1
11809
by: Greg Teets | last post by:
I have a field in an access 2000 database that is actually three lines of text separated by carriage returns. Is there a function in the Access version of SQL that will let me locate the carriage returns and then split the field based on the positions of the carriage returns? Or do I need to process the field with Visual Basic? I seached for an answer to this on the web. I found an answer that
2
2945
by: eagleofjade | last post by:
I am trying to import data from a Word document into an Access table with VBA. The Word document is a form which has various fields. One of the fields is a field for notes. In some cases, this note field contains carriage returns. When I import a note field that has carriage returns, what shows up in the Access field are vertical black lines where the carriage return should be.
1
2664
by: I am Sam | last post by:
In ASP using VBScript to replace Chr(13) or Chr(10) with a <br> tag I would use the Replace method so that I can catch carriage returns from a memo field in MS Access or a Text field in MS SQL Server. For instance <%=Replace(rs.Fields.Item("column").Value),Chr(13),"<br />")%>. I am, now, migrating to ASP.NET 1.1 and am using C# as the primary programming language. In one of my contracts I have a database table with a field that must be a...
3
26329
by: Smythe32 | last post by:
Hi All, I am trying to remove carriage returns from a text field via some code. Here is an example of what I am up against. The field streetname contains the little square box that I believe is a carriage return. So, the field will have text, the little square box and more text. I
3
53287
by: ics3djc | last post by:
Hi. Is there a way to remove carriage returns and line feeds from a field in SQL. Here is what I have at the moment: CAST(m.Description AS VARCHAR(8000))AS "Product Description" (have had to cast as VarChar because of problems with aggregate functions in rest of query).
6
13537
by: shajias | last post by:
Hi, I am having a xml code like this <name> I am having a carriage return here. Second line with carriage return. This is the last line. </name>
11
12594
by: evenlater | last post by:
My db allows the user to send email via CDO. The body of the email is determined in code. I have built an email form with To, CC and Subject lines and a large text box for the body of the message so the user can edit the default email message body before sending the message. But when I populate the large text box (txtBody), I can't get it to include the carriage returns. I've tried vbNewLine, vbCrLf, Chr(10) and Chr(13). I've got the...
0
8610
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.