Insert carriage return

bmal

Registered User.
Local time
Today, 02:15
Joined
Sep 23, 2013
Messages
30
hello.

I am trying to reformat a string of text so that it is easier to read on a report.

Based on the text, it seems like the best thing to do is to insert a carriage return before a date/time stamp.

Here is the data (it's a conversation log)...it is three unique conversation log entries:

04/13/2014 8:21PM - all work and no play is no fun - Bob Smith04/13/2014 8:21PM - this is a test of the emergency broadcast system - Bob Smith04/13/2014 8:20PM - log testing - Bob Smith

If the carriage return is before the date/time string, then all entries would look the same. If the carriage return is after the date/time string, it would mess up the first one (I think).

A user had suggested a child table to break out the data into separate records, but I'm sad to say that I never worked with child tables.

Does anyone have a suggestion for replacing 'Date/time stamp' with 'carriage return' & 'Date/time stamp"
 
The code below is attached to a button. txtComment is a control bound to a memo field, and stores all the comments. ShortName is the name of the commentator, previously saved in the TempVars.

When the user clicks the button, it inserts a new line at the top of the text (preceding all already existing text) containing the date, time and name of commenter, and a blank line, and puts the cursor at the begining of the blank line.


Code:
Private Sub cmdComment_Click()
    Dim myString As String
    myString = Format(Now(), "dd-mmm-yy hh:mm") & " " & TempVars.Item("ShortName") & vbCrLf & vbCrLf
    Me.txtComment = myString & Me.txtComment 
    Me.txtComment .SetFocus
    Me.txtComment .SelStart = Len(myString) - 2
End Sub
 
Thank you, spikepl, for that.

Perhaps I am too novice to understand how to use that in this example. Furthermore, I probably did not explain my situation clearly, either.

I am making a report from a query. The field of interest is a conversation log which does not lend itself to friendly display.

My goal is to break the field value apart using a carriage return (I presume) so that each convo log entry looks better in a report.

A sample database is attached. You can see that the convolog field (in this case) is 3 separate entries but they are not too user friendly to read in a report.

spikepl, can I use your module for something like this? I hope my question makes sense.

Thanks for any input.
 

Attachments

Users who are viewing this thread

Back
Top Bottom