Run code once form is sent

  • Thread starter Thread starter LDMueller
  • Start date Start date
L

LDMueller

I created a form in Outlook 2003 with a command button. The code behind the
button is as follows:

Sub cmdScheduleNotification_Click()

dte = FormatDateTime(Item.UserProperties("Laptop Needed Date"), vbShortDate)
tme = FormatDateTime(Item.UserProperties("Laptop Needed Time"), vbShortTime)

Set myItem = Application.CreateItem(1)
myItem.MeetingStatus = 1
myItem.Subject = "Issue Equipment"
myItem.Location = "Equipment is for " & Item.UserProperties("For")
myItem.Start = CDate(dte & " " & tme)
myItem.Duration = 0 'was 90
myItem.ReminderMinutesBeforeStart = 30 '1 day reminder = 1440, 1 week =
10080
myItem.BusyStatus = Free

Set myRequiredAttendee = myItem.Recipients.Add ("LDM")
myRequiredAttendee.Type = 1
Set myOptionalAttendee = myItem.Recipients.Add ("JDE")
myOptionalAttendee.Type = 2
myItem.Send

msgbox "Notification has been Scheduled"

End Sub

This code works fine, however, instead of running the code by pressing the
command button, I'd rather the code run once the user presses "SEND" (after
of course they complete the form).

Can someone help me with this.

Thanks in advance!

LDMueller
 
In the form code window select Script, Event Handler. Add the Send event to
the code.
 
Back
Top