Spacing

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

Spacing

Post by D Willett »

Hi. The following code is placed on a comment form allowing the user to comment against a record. Works fine but once a few comments appear they all look blended into each other. Can a blank line be placed after each session of comment or better still a separator line?

Code: Select all

Private Sub Command20_Click()
    'Message box function for comments
    'Asks if the user wants to save the comment or exits
    Dim intButSelected As Integer, intButType As Integer
    Dim strMsgPrompt As String, strMsgTitle As String
        strMsgPrompt = "Save Comment,(Yes).      Return To Comment And Edit,(No)"
        strMsgTitle = "Comment Save or Edit"
        intButType = vbYesNo + vbDefaultButton1
        intButSelected = MsgBox(strMsgPrompt, intButType, strMsgTitle)
    If intButSelected = vbYes Then
        Me.Refresh
    If Len(Me![TempComments]) > 0 Then
    'Date stamps comments
               
        Me![Comments] = Format(Now, "dd-mm-yyyy hh:mm") & ": " & strUser & " -" & Me![TempComments] & vbNewLine & Me![Comments]
        Me![TempComments] = ""
        End If
        DoCmd.Close acForm, Me.Name
Else
    SendKeys "{backspace}"
    DoCmd.Close acForm, Me.Name, acSaveNo
End If
End Sub
example output:
You do not have the required permissions to view the files attached to this post.
Cheers ...

Dave.

User avatar
HansV
Administrator
Posts: 78484
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Spacing

Post by HansV »

You could change

Code: Select all

        Me![Comments] = Format(Now, "dd-mm-yyyy hh:mm") & ": " & strUser & " -" & Me![TempComments] & vbNewLine & Me![Comments]
to

Code: Select all

        Me![Comments] = Format(Now, "dd-mm-yyyy hh:mm") & ": " & strUser & " -" & _
            Me![TempComments] & vbNewLine & vbNewLine & Me![Comments]
[c/ode]
or to

[code]        Me![Comments] = Format(Now, "dd-mm-yyyy hh:mm") & ": " & strUser & " -" & _
            Me![TempComments] & vbNewLine & "----------" & vbNewLine & Me![Comments]
Best wishes,
Hans

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

Re: Spacing

Post by D Willett »

Brilliant Hans, both versions will suit the purpose.

Kind Regards
Cheers ...

Dave.