Results 1 to 2 of 2
  1. #1
    Star Lounger
    Join Date
    Feb 2002
    Thanked 0 Times in 0 Posts

    Adding to comments (A2000)

    I saw this while searching, it works for me, I have this attached to a hidden footer, on a button.

    Private Sub Command11_Click()
    If Len(Me![TempComments]) > 0 Then
    Me![Comments] = Format(Now, "ddd/mm/yy hh:mm") & ": " & Me![TempComments] & vbNewLine & Me![Comments]
    Me![TempComments] = ""
    End If
    End Sub

    I call the code using the following with key preview and Keydown:

    Private Sub TempComments_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 116 Then Call Command11_Click
    End Sub

    It only works when pressing {F5} twice, any suggestions on how to remedy this.


    Just a couple of variations if possible:

    1/ Is it possible to leave a blank line between each added comment.
    2/ Each time a comment is added, it adds from the top of the field and cascades downwards, is it possible to cascade from the bottom instead.
    Doesn't matter if these two can't be acheived

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Sacramento, California, USA
    Thanked 1 Time in 1 Post

    Re: Adding to comments (A2000)

    F5 is an assigned keyboard shortcut in Windows, but it didn't misbehave for me when I tried it. Your code would be easier to understand, though, if you used the built-in keycode constants like vbKeyF5 instead of their numeric equivalent. You also should make it a rule to reset the KeyCode to 0 if you aren't going to allow the system to actually use follow the KeyDown instructions. Otherwise, you can get highly unexpected results.

    As for your other question, Access is doing exactly what you told it to. This line:

    Me![Comments] = Format(Now, "ddd/mm/yy hh:mm") & ": " & Me![TempComments] & vbNewLine & Me![Comments]

    tells Access add the date and temp comments to the front of the string.

Posting Permissions

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