PC Review


Reply
Thread Tools Rate Thread

Add a date stamp to the note field of a custom form

 
 
007
Guest
Posts: n/a
 
      16th Dec 2009
I am using the following code to add a button that inserts a time and date
field in the note section of a custom contact form.

Sub StampDate()
Item.Body = Now() & vbCrLf & vbCrLf & Item.Body
End Sub

Sub CommandButton3_Click()
Call StampDate()
End Sub

There are a few bugs I need to fix.
1) I would like to add the user name.
2) My note field has some files that I have dragged to the top of the note
field and when I click the command button, the date text gets jumbled up
around the files. So I would like the date stamp to be inserted below the
files at the top.

Any help would be greatly appreciated.

 
Reply With Quote
 
 
 
 
brightenmyoutlook
Guest
Posts: n/a
 
      17th Dec 2009
On Dec 16, 10:07*am, 007 <0...@discussions.microsoft.com> wrote:
> I am using the following code to add a button that inserts a time and date
> field in the note section of a custom contact form.
>
> Sub StampDate()
> Item.Body = Now() & vbCrLf & vbCrLf & Item.Body
> End Sub
>
> Sub CommandButton3_Click()
> Call StampDate()
> End Sub
>
> There are a few bugs I need to fix.
> 1) I would like to add the user name.
> 2) My note field has some files that I have dragged to the top of the note
> field and when I click the command button, the date text gets jumbled up
> around the files. So I would like the date stamp to be inserted below the
> files at the top.
>
> Any help would be greatly appreciated.

++++++++++++++++++++++++++++++++++++++++++++++++++++++

The modified code below should return the User Name for you.

Sub StampDate()
Item.Body = Application.GetNamespace("MAPI").CurrentUser & " - " &
Now() & vbCrLf & vbCrLf & Item.Body
End Sub

Sub CommandButton3_Click()
Call StampDate()
End Sub


As far as the attachments are concerned, you should place them at the
bottom of the note field. If they must remain on the top, then you
will have to write some code that removes all existing attachments,
inserts your date/time stamp, then adds attachments back into note
field. You can use the code below as a starting point although I
believe this is more effort than its worth.

Sub CopyAttachments (objSourceItem, objTargetItem)
Dim fso As Object
Dim fldTemp As Object
Dim objAtt As Attachment
Dim strPath As String
Dim strFile As String

Set fso = CreateObject ("Scripting.FileSystemObject")
Set fldTemp = fso.GetSpecialFolder(2)
strPath = fldTemp.Path & "\"
For Each objAtt In objSourceItem.Attachments
strFile = strPath & objAtt.FileName
objAtt.SaveAsFile strFile
objTargetItem.Attachments.Add strFile, , , objAtt.DisplayName
fso.DeleteFile strFile
Next objAtt

Set objAtt = Nothing
Set fldTemp = Nothing
Set fso = Nothing
End Sub


The modified code below should return the user for you.

Sub StampDate()
Item.Body = Application.GetNamespace("MAPI").CurrentUser & " - " &
Now() & vbCrLf & vbCrLf & Item.Body
End Sub

Sub CommandButton3_Click()
Call StampDate()
End Sub


As far as the attachments are concerned, you should place them at the
bottom of the note field. If they must remain on the top, then you
will have to write some code that removes all existing attachments,
inserts your date/time stamp, then adds attachments back into note
field. You can use the code below as a starting point although I
believe this is more effort than its worth.

Sub CopyAttachments (objSourceItem, objTargetItem)
Dim fso As Object
Dim fldTemp As Object
Dim objAtt As Attachment
Dim strPath As String
Dim strFile As String

Set fso = CreateObject ("Scripting.FileSystemObject")
Set fldTemp = fso.GetSpecialFolder(2)
strPath = fldTemp.Path & "\"
For Each objAtt In objSourceItem.Attachments
strFile = strPath & objAtt.FileName
objAtt.SaveAsFile strFile
objTargetItem.Attachments.Add strFile, , , objAtt.DisplayName
fso.DeleteFile strFile
Next objAtt

Set objAtt = Nothing
Set fldTemp = Nothing
Set fso = Nothing
End Sub

Brian McOutlook
www.brightenmyoutlook.com | Outlook Customization
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access Note table in date order, when go to note form, dates are n Rachel Rollins Microsoft Access Database Table Design 1 10th Dec 2009 07:14 PM
Custom IPM.Note Form - Message Field Trouble =?Utf-8?B?ZnJlZXNpbmU=?= Microsoft Outlook Form Programming 1 11th Aug 2006 03:50 AM
date stamp Can I add a date stamp in a Text or Memo Field =?Utf-8?B?TWljaGFlbCBM?= Microsoft Access Database Table Design 10 11th Apr 2005 02:29 AM
Date stamp in a note field T Hart Microsoft Access Forms 5 13th Jul 2004 10:02 PM
Date/Time Stamp in Contacts Note Field WRC Microsoft Outlook Contacts 2 16th Apr 2004 06:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:34 PM.