By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,966 Members | 1,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,966 IT Pros & Developers. It's quick & easy.

Memo field formatting

P: 10
I have a memo field that time/date stamps new entries to the field. What Iím trying to do is for entries that are more than 1 line, the second or subsequent lines are moved under the first line past the time and date stampÖAny code would be appreciated. Thanks
Oct 7 '08 #1
Share this Question
Share on Google+
4 Replies

Expert 5K+
P: 8,679
Kindly post a concrete example of what contents of the Memo Field would look like both prior to, and after, reformatting.
Oct 8 '08 #2

P: 10
Kindly post a concrete example of what contents of the Memo Field would look like both prior to, and after, reformatting.
The memo feild looks similar to this now:
Expand|Select|Wrap|Line Numbers
  1. 10/10/2008 11:30:00 Interviewed Subj while at Childrns Court.  Subj stated same about the nails stated that the only reason that he pulled over was to check his tires and vic started  TT to him.  Advised will look into situation.
What I would like to do is similar to this:
Expand|Select|Wrap|Line Numbers
  1. 10/10/2008 11:30:00 Interviewed Subj while at Childrns Court.  Subj stated 
  2.                     same about the nails stated that the only reason he 
  3.                     pulled over was to check his tires and vic started  
  4.                     TT to him.  Advised will look into situation.
(I can't get the formatting correct in this post, so please bear with me)

However, each line would be single spaced. (No line numbers) The date/time stamp would 'stick out' on each new entry.

I hope I explained this so you can understand it. Thanks for your input.
Oct 8 '08 #3

Expert Mod 15k+
P: 31,709
That's fine as far as it goes, but you mention subsequent entries in your original post without any example included to help us determine what you mean.

On the same track, you don't ask about formatting the field to display as your example indicates you require. There seems to be little if any correlation between your question and your example.
Oct 8 '08 #4

Expert 5K+
P: 8,679
Here is some rather crude and simple code which will achieve the basic formatting that you are requesting. The code resides in the Form's Current() Event, reads the contents of a Field named txtMEMO bound to a MEMO Field, then formats each line based on the Indentation from the length of the Time Stamp, and places the results in a Field named txtMEMO2. I hid then actual MEMO Field (txtMEMO) on the Form, so the User only sees txtMEMO2. As previously stated, it is very crude, and you will have to experiment with the Line Length Constant, as well as Font Names and Sizes. It will hyphenate words at the Line Length since I haven't work out the logic to break only at spaces, and will not do so unless I know that this is what you are looking for. Any questions, feel free to ask.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. Dim lngCharCounter As Long
  3. Dim lngPos As Long
  4. Dim strBigString As String
  5. Const conLENGTH_OF_LINE As Long = 75
  6. Const conLENGTH_OF_TIMESTAMP As Integer = 16
  8. If IsNull(Me![txtMEMO]) Then Exit Sub
  10. lngCharCounter = Len(Me![txtMEMO])
  12. For lngPos = 1 To lngCharCounter
  13.   If lngPos Mod conLENGTH_OF_LINE = 0 Then
  14.     strBigString = strBigString & "_" & vbCrLf & Space$(conLENGTH_OF_TIMESTAMP * 2) & _
  15.                    IIf(Mid$(Me![txtMEMO], lngPos, 1) = " ", "", Mid$(Me![txtMEMO], lngPos, 1))
  16.   Else
  17.     strBigString = strBigString & Mid$(Me![txtMEMO], lngPos, 1)
  18.   End If
  19. Next
  21. Me![txtMEMO2] = strBigString
  22. End Sub
Contents of txtMEMO2 for your demo Text, based on Arial 11:
Expand|Select|Wrap|Line Numbers
  1. 10/10/2008 11:30:00 Interviewed Subj while at Childrns Court.Subj stated_                             
  2.                     same about the nails stated that the only reason that he pulled over was t_
  3.                     o check his tires and vic started  TT to him.  Advised will look into situa_
  4.                     tion.
Oct 8 '08 #5

Post your reply

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