0
votes

I have a simple MS Access database with a memo field that stores comments via AppendOnly.

In one of the forms I would like to add a "Add comment" button which would open/pop up a small text field/window where the user can enter a new comment which then get added to the memo field. Can anyone help me with this?

Extra feature: I can read the Windows username through a function - how could I add that username to the comment string (e.g. "User u123: [his comment from the popup window]")?

1

1 Answers

0
votes

For a very barebones comment input you can use InputBox

To append your comment and username you can concatenate the strings to your existing memo field

Something like this (for a button called Add_Comment):

Private Sub Add_Comment_Click()
    Dim strComment As String
    Dim strUser    As String

    strComment = InputBox("Add Your Comment" , "Comment")

    If strComment <> "" Then ' User did not hit Cancel

         ' Prepend Username using your function   
         strComment = GetUserName() & ": [" & strComment & "]"

         ' Append Comment to end of Memo field separated by <CR><LF>
         Me![My Memo Fieldname] = Me![My Memo Fieldname] & vbcrlf & strComment
         Msgbox "Comment Appended"
    Else
         Msgbox "No Comment Added"
    End If
End Sub