709-218-7927

The Landfall Garden House

60 Canon Bayley Road

Bonavista, Newfoundland

CANADA A0C 1B0

CPRGreaves@gmail.com

Home

Christopher Greaves

Augmenting Comments

Suppose you have a memo field in which you type comments about the recent contact. The memo field will gradually fill up with comments, but you would like the most recent comment to be at the top/front, and prefixed by the date on which you had the conversation.

This lesson will be similar to the previous lesson. In design mode, create a Command Button near your comments (or "memo") field. When the Command Wizard box pops up, choose Cancel to discard it. We don't need Wizards. We are Wizards!

Right-Click on the new control to raise the Properties box, and change its name to "cmdComments" and the caption to be "Today".

Still in the Properties box, locate the "On Click" event; choose the triple-period button and elect for the Code Builder.

You will be launched into the VBE with a small procedure that looks just like this:

Private Sub cmdComments_Click()
End Sub

Type the code shown below to complete the procedure:

Private Sub cmdToday_Click()
Me.COMMENTS.SetFocus
Dim strComments As String
strComments = Format(Date, "YYYY/MM/DD")
strComments = strComments & " // " & Me.COMMENTS.Text
Me.COMMENTS = strComments
Me.COMMENTS.SelStart = 11
End Sub

Close your design window.

Back in your user form you'll see your new command button, with a caption "Today".

Click on your "Today" button.

You should see the today's date appear with a couple of forward slashes, and your text cursor should be placed ready for you to start typing a record of today's conversation with your client.

That will be exactly eleven characters into the augmented field (refer to the SelStart property), being eight characters for the formatted date plus two slash characters plus a space.

If you accidentally clicked in a field that was empty, that contained no comments, you received no warning message. Why is that?

709-218-7927 CPRGreaves@gmail.com

Bonavista, Sunday, December 08, 2024 9:30 AM

Copyright © 1990-2024 Chris Greaves. All Rights Reserved.