Is it possible to indent a memo field?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Thomas Bea
    New Member
    • Oct 2010
    • 2

    Is it possible to indent a memo field?

    Hello. I have a memo field that has is timestamped. I need the field to indent past the date and time.

    The field looks like this:

    10/11/2010 2:48:14 PM Talked to lady stated that
    Defendant was at place of employment yesterday.....
    10/11/2010 2:48:17 PM Status is: Closed

    I want it to look like this: (Minus the'------')

    10/11/2010 2:48:14 PM Talked to lady stated that
    --------------------------------Defendant was at place of
    --------------------------------employment yesterday...... .
    10/11/2010 2:48:14 PM Status is: Closed.

    I hope you can understand what i'm trying to do. And I thank you for looking at my question. (I'm using Access 2007)
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1293

    #2
    Thomas,
    Hello, welcome to Bytes.

    You cannot indent only the first line of a memo and not the remainder, or vice versa. So you'll need to split the memo into two parts, a date part and a part without the date.

    You will need two text fields instead of one, the first for the date and the second for the memo. Is this a report or a form you are looking at? In a report you would add this code to the Detail OnFormat event:

    Code:
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Dim intDateEnds As Integer
    
    On Error GoTo Err_DetailFormat
    
    intDateEnds = InStr(Me!memNote, "M ") ' find the end of the date/time PM or AM
    Me!txtDate = Left(Me!memNote, intDateEnds) ' get the date and time only
    Me!txtNote = Mid(Me!memNote, intDateEnds + 2) ' get the note after the date/time
    
    Exit Sub
    
    Err_DetailFormat:
        MsgBox Err.Description
        Resume Next
    
    End Sub
    In this code
    memNote is a text box bound to the data field. It should be invisible and the Can Grow property should be false
    txtDate is the text box to contain the date field only
    txtNote is the text box to contain the part of the note without the date. The Can Grow property should be true, and probably the Can Shrink property also, but that is up to you.

    If you are working with a form and not a report, things are trickier because you cannot have unbound text boxes within the detail. You would have to split the content up in the query and then bind the separate parts to text boxes.

    Hope this helps,
    Jim

    Comment

    • Thomas Bea
      New Member
      • Oct 2010
      • 2

      #3
      Thanks Jim for you fast answer.

      Using the code works only on the first line of the memo field. The rest of the field on the report is the same. Maybe I'm doing something wrong.

      Thomas

      Comment

      • jimatqsi
        Moderator Top Contributor
        • Oct 2006
        • 1293

        #4
        I don't see how that can be. If the memo is in a separate text box, the top line of the memo cannot be more or less left or right than the following lines of the memo. The text box is a rectangle with the same bounds on the left and right from top to bottom.

        Can you attach a pdf of your report so we can see the result? I think I am not understanding something about your situation correctly.

        Jim

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32661

          #5
          Jim's provided an interesting and innovative solution that directly matches your question and situation.

          I would suggest you go further and store the date separately in your data. It makes little sense to store it as part of the Memo field, and no good comes from it.

          Comment

          • Freddyboy
            New Member
            • Feb 2022
            • 2

            #6
            indent following text

            Originally posted by NeoPa
            Jim's provided an interesting and innovative solution that directly matches your question and situation.

            I would suggest you go further and store the date separately in your data. It makes little sense to store it as part of the Memo field, and no good comes from it.
            I would try in your text field: FormatDate(your date field formatted to your liking) & Chr(13) & Chr(10) & " " & next datafield.

            To over simplify, Textbox = Date & Chr(13) & Chr(10) & datafield

            This will line feed your data after displaying the date. the Chr characters line feed, then your data follows the spaces entered by using & and then your textfield

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32661

              #7
              I'd be inclined to avoid that myself. Read my earlier post for my warning against storing the data in a Memo field at all.

              If, for whatever reason, you do need to include a Carriage Return / Line Feed sequence into your data from VBA then there are two constants (vbNewLine & vbCrLf) that contain the whole sequence and make working with it easier & clearer for anyone reading it.

              Mixing two disparate entities together is a particularly clumsy way to approach handling such data and should be avoided where possible.

              Comment

              Working...