Date stamping a text or memo field problem

  • Thread starter BBC via AccessMonster.com
  • Start date
B

BBC via AccessMonster.com

I have some fields (text or memo) that I am tring to date/time stamp using a
cmdbutton to execute the following code;
Private Sub DateTimeStamp()
Dim StampText As String
Me.Comment.SetFocus
Me.Comment.SelStart = 0
StampText = "[ " & Format(Date, "dd-mmm-yy") & " " & Format(Time, "hh:
mm ampm") & " ] "
Me.Comment = StampText & vbCrLf & Me.Comment
Me.Comment.SelStart = Len(StampText) + 1
End Sub

It inserts the date/time but does not add the 2 spaces after the last " ] "
(adds none) and it does not put a CrLf between the between the stamp and the
existing comment data. In fact it seems to leave the cursor in various
placed from right next to the last "]" to withing the first couple of
characters in the existing comment. I've tried 2x CrLf and adjusting the
last .SelStart, nothing seems to help.
Any help or suggestions appreciated.

I'd actually like to make this a common function and have the cmdbutton put
the stamp in the immediately (just previously) selected text or memo field
but not sure how to accomplish that (passing the form/control to the common
routine)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top