473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to add CR/LF to a forms .value text box

I am trying to add the cr/lf characters to a form text box. I have used both text and a memo field that is set for Rich Text. I can add them to a string, display the string in a message box - but when I move the string to the forms field the CR/LF are being stripped out. I do not know how to overcome that. Here is a snippet of code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub ParentParcel_DblClick(Cancel As Integer)
  2. 'On Error GoTo EndSub
  3. '
  4. ''''''
  5. '
  6. ''''''
  7. Dim NewParentParcel As String
  8. Dim CurrentParentParcel As String
  9. Dim TempMapBookPage As String
  10. Dim strSQL As String
  11. Dim response As String
  12. '
  13. TempMapBookPage = "'" & MapBookPage & "'"
  14. CurrentParentParcel = ParentParcel
  15. TempMapBookPage = "'37/110'"
  16. 'MsgBox (TempMapBookPage)
  17. strSQL = "SELECT * FROM ParentParcelsTable where MapBookPage=" & TempMapBookPage & "order by ParentParcels"
  18. '
  19. Dim dbs As DAO.Database
  20. Dim rstMapQuery As DAO.Recordset
  21. '
  22. Set dbs = CurrentDb
  23. Set rstMapQuery = dbs.OpenRecordset(strSQL, dbOpenSnapshot)
  24. '
  25. Do Until rstMapQuery.EOF
  26.     If NewParentParcel = "" Then
  27.       NewParentParcel = rstMapQuery.Fields("ParentParcels")
  28.     Else
  29.        NewParentParcel = NewParentParcel & vbCrLf & _
  30.          rstMapQuery.Fields("ParentParcels")
  31.     End If
  32.     response = MsgBox(NewParentParcel, vbYesNo)
  33.     ' after this statement I can see the parcel numbers displayed    
  34.   rstMapQuery.MoveNext
  35. '
  36. Loop
  37. '
  38. EndSub:
  39. '
  40. rstMapQuery.Close
  41. Set rstMapQuery = Nothing
  42. Set dbs = Nothing
  43. '
  44. MsgBox ("final result = " & NewParentParcel)
  45. Forms("RecordedMapsForm").ParentParcel.Value = NewParentParcel
  46. Me.Refresh
  47. '
  48. End Sub
Sep 12 '08 #1
14 5847
ADezii
8,834 Expert 8TB
To add a Carriage Return/Line Feed combination to any String:
Expand|Select|Wrap|Line Numbers
  1. strAnyString & vbCrLf
Sep 12 '08 #2
Thanks ADezii for the quick reply. Please take a look at line 30. At line 46 where the data goes back to the form - they are stripped out for some reason.
Sep 13 '08 #3
ADezii
8,834 Expert 8TB
Thanks ADezii for the quick reply. Please take a look at line 30. At line 46 where the data goes back to the form - they are stripped out for some reason.
Can't think of any reason why they would be. Instead of vbCrLf, you can use:
Expand|Select|Wrap|Line Numbers
  1. Chr$(13) & Chr$(10)
Sep 13 '08 #4
I have used vbNewline and the chr(n) codes as well. They all display correctly in the msgbox at ine 33, but after the statement at line 46 the strings are concatenated without the CR/LF. Maybe there is another work-around?
Sep 13 '08 #5
ADezii
8,834 Expert 8TB
I have used vbNewline and the chr(n) codes as well. They all display correctly in the msgbox at ine 33, but after the statement at line 46 the strings are concatenated without the CR/LF. Maybe there is another work-around?
Type the following into the Debug Window (CTRL+G):
Expand|Select|Wrap|Line Numbers
  1. ? "Herman" & vbCrLf & "Munster"
You should see:
Expand|Select|Wrap|Line Numbers
  1. Herman
  2. Munster
Is this the case?
Sep 13 '08 #6
Hello ADezii - yes I see it (without the 1. and 2. of course). It would be nice if I could include a screenshot of the msgbox to show you.
Sep 13 '08 #7
ADezii
8,834 Expert 8TB
Hello ADezii - yes I see it (without the 1. and 2. of course). It would be nice if I could include a screenshot of the msgbox to show you.
You never actually answered Post #6, do you see
Expand|Select|Wrap|Line Numbers
  1. Herman
  2. Munster
when you type ?
Expand|Select|Wrap|Line Numbers
  1. "Herman" & vbCrLf & "Munster"
  2.  
Sep 13 '08 #8
Yes - I see it in the Immediate Window as you said. Thanks.
Sep 13 '08 #9
ADezii
8,834 Expert 8TB
Yes - I see it in the Immediate Window as you said. Thanks.
Try the code in a Standard Text Box and see what happens.
Sep 14 '08 #10
It works in the standard text box. It seems to work everywhere except at line 46 - where it does not work. There is something the compiler is doing to remove the CR/LF's from the stream before in goes back to the form. The form field from line 46 looks like this:
09-2-03-1-001-008.000 09-2-03-1-001-009.000 09-2-03-1-001-010.001 09-2-03-1-001-010.002

I want it to look like this:

09-2-03-1-001-008.000
09-2-03-1-001-009.000
09-2-03-1-001-010.001
09-2-03-1-001-010.002

And this is what the msgbox displays.
Sep 14 '08 #11
ADezii
8,834 Expert 8TB
It works in the standard text box. It seems to work everywhere except at line 46 - where it does not work. There is something the compiler is doing to remove the CR/LF's from the stream before in goes back to the form. The form field from line 46 looks like this:
09-2-03-1-001-008.000 09-2-03-1-001-009.000 09-2-03-1-001-010.001 09-2-03-1-001-010.002

I want it to look like this:

09-2-03-1-001-008.000
09-2-03-1-001-009.000
09-2-03-1-001-010.001
09-2-03-1-001-010.002

And this is what the msgbox displays.
Would it be possible for you to send me the DB as an E-Mail Attachment? I'm currently on vacation, but the problem is that I am not running Access 2007 but when I get into work next week, I'll be more than happy to have a look at it for you. Kindly let me know one way or the other.
Sep 15 '08 #12
Thanks ADezii for the extra nice offer. I would not put you out like that. Maybe, I will continue to experiment for other work-arounds and hit on something. I'll repost if I get a solution. Thanks much.
Sep 15 '08 #13
I found a work-around for the problem. You cannot have the field on the form set for Rich Text. I deleted the field from the form. Saved/Closed the form and changed the table field from Memo to Text, size=255. Re-added the field back to the form and re-ran the same procedure. This time it produced the same results as the msgbox had been displaying all along. The Rich Text option must cause the CR/LF to be removed. I hope this helps someone else in the future.
Sep 15 '08 #14
ADezii
8,834 Expert 8TB
I found a work-around for the problem. You cannot have the field on the form set for Rich Text. I deleted the field from the form. Saved/Closed the form and changed the table field from Memo to Text, size=255. Re-added the field back to the form and re-ran the same procedure. This time it produced the same results as the msgbox had been displaying all along. The Rich Text option must cause the CR/LF to be removed. I hope this helps someone else in the future.
Thanks for sharing this information with us.
Sep 15 '08 #15

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

Similar topics

2
by: Richard | last post by:
**** Post for FREE via your newsreader at post.usenet.com **** HI, I am working on a project where I need to input data to a (local) HTML page using multiple form elements, such as text,...
3
by: brett | last post by:
Using DOM in IE, how can I loop through FORMs and access FORM elements in a specific form? For example, www.hotmail.com has about 13 forms. I believe the one displayed is dependent on the URL. If...
2
by: Mark Hannon | last post by:
I am designing a PayPal shopping cart/store for a client and have placed several of PayPal's shopping cart forms on the page to correspond with different products. Each form has a unique name...
3
by: Kris van der Mast | last post by:
Hi, I've created a little site for my sports club. In the root folder there are pages that are viewable by every anonymous user but at a certain subfolder my administration pages should be...
0
by: Anonieko Ramos | last post by:
ASP.NET Forms Authentication Best Practices Dr. Dobb's Journal February 2004 Protecting user information is critical By Douglas Reilly Douglas is the author of Designing Microsoft ASP.NET...
7
by: Sergey Poberezovskiy | last post by:
Hi, I created two base forms: frmList and frmDetail, compiled them into a dll, and then want to use in my new project. The problem: When I created new inherited form, say frmClients, I cannot...
19
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect...
5
by: ankit1999 | last post by:
I have a problem, everytime i'm run this page http://click2travel.in/index.php i get the this error,,,
5
by: lolodede | last post by:
i have form that contain different questions i put star for mandatory questions others left it without it then i put this java script to validate this mandatory but still ask the user to fill even...
5
by: programmerboy | last post by:
I never had this kind of issue before and it is completely surprising. I have a usercontrol where I need 2 forms to make 1 form. When I have only 1 form it submits the page to itself. I have spent...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.