Results 1 to 9 of 9

Thread: newline code

  1. #1
    Join Date
    Jan 2015
    Posts
    23

    Post Unanswered: newline code

    Good day, pls i'm dispirately in need of a command button code that will enable me go to a new line after some coding. I need a line break each time a new data is entered. This will help me avoid mixup. Any assitance will be appreciated... thanks

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Im not to sure what you are trying to achieve
    in VBA vbcrlf is an inherent constant for Carriage Return and Line Feed.

    eg:
    Code:
    myvar = 'A VBA coding style announcement' & vbcrlf & ' Would all would be VBA coders please use the inherent VB constants....'
    if its whilst entering data in a text box pressing the control key (Ctrl) and enter will add a new line symbol into the data stream

    but
    after some coding..
    that's a new one on me, whilst in the VBA code window pressing enter does the job...
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jan 2015
    Posts
    23

    line break

    Tanks for your response. My current code is from this site which is


    Code:
    Private Sub Confirm_Click()
    'This line checks to assure that the TempNotes field is not empty. If it ' is empty nothing happens (this prevents just the date from being added)
    If Not IsNull(Me.TempNotes) And Me.TempNotes <> "" Then

    'This checks if ClientNotes is empty and if so simply adds the
    ' date and TempNotes to ClientNotes
    If IsNull(Me.ClientNotes) Or Me.ClientNotes = "" Then
    Me.ClientNotes = Now & ": " & Me.TempNotes
    'This line blanks out the TempNotes
    Me.TempNotes = ""
    Else 'If there's already data in ClientNotes this adds the new notes
    ' to the old
    Me.ClientNotes = Me.ClientNotes & " " & Now & ": " &
    Me.TempNotes
    'This line blanks out the TempNotes
    Me.TempNotes = ""
    End If
    End If
    End Sub


    I need a line break before and after the "Now" (Time coding) to differenciate new data and older ones. Thanks and sorry for many questions am just a beginer.

  4. #4
    Join Date
    Jan 2015
    Posts
    23

    line break

    Tanks for your response. My current code is from this site which is


    Code:
    Private Sub Confirm_Click()
    'This line checks to assure that the TempNotes field is not empty. If it ' is empty nothing happens (this prevents just the date from being added)
    If Not IsNull(Me.TempNotes) And Me.TempNotes <> "" Then

    'This checks if ClientNotes is empty and if so simply adds the
    ' date and TempNotes to ClientNotes
    If IsNull(Me.ClientNotes) Or Me.ClientNotes = "" Then
    Me.ClientNotes = Now & ": " & Me.TempNotes
    'This line blanks out the TempNotes
    Me.TempNotes = ""
    Else 'If there's already data in ClientNotes this adds the new notes
    ' to the old
    Me.ClientNotes = Me.ClientNotes & " " & Now & ": " &
    Me.TempNotes
    'This line blanks out the TempNotes
    Me.TempNotes = ""
    End If
    End If
    End Sub


    I need a line break before and after the "Now" (Time coding) to differenciate new data and older ones. Thanks and sorry for many questions am just a beginer.

  5. #5
    Join Date
    Jan 2015
    Posts
    23

    Post line break

    Tanks for your response. My current code is from this site which is similar to


    Code:
    Private Sub Confirm_Click()
    'This line checks to assure that the TempNotes field is not empty. If it ' is empty nothing happens (this prevents just the date from being added)
    If Not IsNull(Me.TempNotes) And Me.TempNotes <> "" Then

    'This checks if ClientNotes is empty and if so simply adds the
    ' date and TempNotes to ClientNotes
    If IsNull(Me.ClientNotes) Or Me.ClientNotes = "" Then
    Me.ClientNotes = Now & ": " & Me.TempNotes
    'This line blanks out the TempNotes
    Me.TempNotes = ""
    Else 'If there's already data in ClientNotes this adds the new notes
    ' to the old
    Me.ClientNotes = Me.ClientNotes & " " & Now & ": " &
    Me.TempNotes
    'This line blanks out the TempNotes
    Me.TempNotes = ""
    End If
    End If
    End Sub


    I need a line break before and after the "Now" (Time coding) to differenciate new data and older ones. Thanks and sorry for many questions am just a beginer.

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so add the constant vbcrlf wherever you need a new line. it doesn't matter if you add it to the preceeding line to give a following new line, of the following line to give a space after the previous one.

    OR manually add the carriage return usign ctrl + enter whilst typing you data

    OR redesign the form so that each comment is a different entry in a sub table, each comment has a separate timestamp as part of the column design. if you dont' allow the user to delete rows and change the date this is a far safer approach as it means that a malicious user cannot cover their tracks by editing the comments
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    Jan 2015
    Posts
    23
    Thanks a million. vbcrlf works perfectly.

  8. #8
    Join Date
    Jan 2015
    Posts
    23
    Good day, pls I hav e two forms sending data to thesame table, one for general and the other for admin. I have also added line break with ur help (vbcrlf). Is is there a way I can differenciate the data from admin and other with alignment, color, italic etc as part of the codes. The code is similar to:

    Code:
    Private Sub Confirm_Click()
    'This line checks to assure that the TempNotes field is not empty. If it ' is empty nothing happens (this prevents just the date from being added)
    If Not IsNull(Me.TempNotes) And Me.TempNotes <> "" Then

    'This checks if ClientNotes is empty and if so simply adds the
    ' date and TempNotes to ClientNotes
    If IsNull(Me.ClientNotes) Or Me.ClientNotes = "" Then
    Me.ClientNotes = Now & ": " & Me.TempNotes
    'This line blanks out the TempNotes
    Me.TempNotes = ""
    Else 'If there's already data in ClientNotes this adds the new notes
    ' to the old
    Me.ClientNotes = Me.ClientNotes & " " & Now & ": " &
    Me.TempNotes
    'This line blanks out the TempNotes
    Me.TempNotes = ""
    End If
    End If
    End Sub

    I tried alignment, color etc on both the TempNote and ClientNote but it affects data fron both sides. Maybe something can be done on the code side.
    Assistance will be appreciated thanks

  9. #9
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    new question
    new thread please
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •