VBA Code on Message form to take me to Appointment form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have Outlook 2003. I have a Message form named Equipment.oft and an
Appointment form named Alarm.oft.

I need to create a button on my Message form which will take me to the
Appointment form. Can anyone help me with the code on this.

Thanks in advance!
 
As you describe it, that's not possible. Code runs only on published forms, not on .oft files. If you change your mind and decide to publish the form, though, take a look at the Application.CreateItemFromTemplate method, which is what you'd use to create a new item from an .oft file.

FYI, there is a newsgroup specifically for Outlook forms issues "down the hall" at microsoft.public.outlook.program_forms or, via web interface, at http://www.microsoft.com/office/com...spx?dg=microsoft.public.outlook.program_forms

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/article.aspx?id=54
 
Sorry I didn't describe it better. I did publish my forms so your suggestion
worked perfectly.

Would you by chance have any code for when the second form opens (e.g. the
Appointment form) so that it sets the focus to the "Start Time" field.

Thanks Sue!
 
That's possible only on custom pages, unless you want to use a SendKeys kludge (which I personally avoid).

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/article.aspx?id=54
 
Okay, then could I somehow code a command button on the form
"IPM.Appointment.IS Notification" so that it copies the data from it's field
named "Needed Date" to a field on another form named "Start Time" which is on
the form named "IPM.Note.IS Equipment Reserve"? Or would this be the same
situation.

Basically what I'm trying to do is this. I have a form named "Equipment
Request" (based off a Message) which has numerous check boxes and drop down
fields. The user completes the form and completes a "needed date" and
"needed time" field on this form. The form is emailed to an IS mailbox and
everyone in the IS department has access to this mailbox.

Once the form arrives in the inbox, someone from IS will look over the form
and reserve some of the equipment and save the form. This provides us with
all our information. What I need is a way of also getting the "needed date"
and "needed time" on everyone calendar without having to manually complete
another form.

Any suggestions would be greatly appreciated.

Thanks!
 
Certainly, if you have published forms, you can put code behind them to copy property values from one item to another. (Terminology alert: The form contains no data. So you are not coping to a field on another form, but to a field on another *item.*)

This would be the easiest approach: If you already have code that creates a new item from a published form, that code should be returning an object variable representing the newly created item. So you would use that object and set its properties to the desired values from the original item, i.e. the item where the code is running. See http://www.outlookcode.com/article.aspx?ID=38 if you need help with property syntax.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/article.aspx?id=54
 
Okay, I tried to go through all this, but some is a little over my head.
Based on your information (which was very helpful I might add), I have gotten
some code which is working, but I have one part which I don't know how to do.

Here's my code...

Sub CommandButton4_Click()
Set myItem = Application.CreateItemFromTemplate _
("C:\Documents and Settings\ldm\Application Data\Microsoft\Templates\IS
Schedule Notification.oft")
myItem.Display
myItem.Start = Item.UserProperties("Laptop Needed Date")
myItem.Start = Item.UserProperties("Laptop Needed Time")
myItem.Send
End Sub

This is a published message form and I have a command button which should
take the "Laptop Need Date" and Laptop Need Time" from the message form and
complete this appointment and send it.

If I leave it as coded above, the date is wrong, but the time is correct.
If I remove the line "myItem.Start = Item.UserProperties("Laptop Needed
Time")" from the above code, the date is perfect, but the time is wrong.

I need to somehow combine the lines, but I haven't found a successful way to
do this and I've tried different variations. Using the logic like this...
myItem.Start = #9/24/97 1:30:00 PM#

I tried to code it like this, but this doesn't work...
myItem.Start = Item.UserProperties("Laptop Needed Date") & " " & ("Laptop
Needed Time")

Any suggestions?
 
What doesn't work with this statement:

myItem.Start = Item.UserProperties("Laptop Needed Date") & " " & ("Laptop Needed Time")

Did you check the value that the expression returns? Are the properties text properties or date/time properties?

Setting Start twice just overwrites the first value with the second.

If the two properties are date/time, what you need to do is use the FormatDateTIme() function to separate the date element from the date field and the time element from the time field. Then combine them into one string and convert to a date with CDate(). Something like this:

dte = FormatDateTime(Item.UserProperties("Laptop Needed Date", vbShortDate)
tme = FormatDateTime(Item.UserProperties("Laptop Needed Date", vbShortTime)
myItem.Start = CDate(dte & " " & tme)

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54

LDMueller said:
Okay, I tried to go through all this, but some is a little over my head.
Based on your information (which was very helpful I might add), I have gotten
some code which is working, but I have one part which I don't know how to do.

Here's my code...

Sub CommandButton4_Click()
Set myItem = Application.CreateItemFromTemplate _
("C:\Documents and Settings\ldm\Application Data\Microsoft\Templates\IS
Schedule Notification.oft")
myItem.Display
myItem.Start = Item.UserProperties("Laptop Needed Date")
myItem.Start = Item.UserProperties("Laptop Needed Time")
myItem.Send
End Sub

This is a published message form and I have a command button which should
take the "Laptop Need Date" and Laptop Need Time" from the message form and
complete this appointment and send it.

If I leave it as coded above, the date is wrong, but the time is correct.
If I remove the line "myItem.Start = Item.UserProperties("Laptop Needed
Time")" from the above code, the date is perfect, but the time is wrong.

I need to somehow combine the lines, but I haven't found a successful way to
do this and I've tried different variations. Using the logic like this...
myItem.Start = #9/24/97 1:30:00 PM#

I tried to code it like this, but this doesn't work...
myItem.Start = Item.UserProperties("Laptop Needed Date") & " " & ("Laptop
Needed Time")
 
Hi Sue,

Once I added a couple of parenthesis , the code was perfect and exactly what
I needed.

dte = FormatDateTime(Item.UserProperties("Laptop Needed Date)", vbShortDate)
tme = FormatDateTime(Item.UserProperties("Laptop Needed Date)", vbShortTime)
myItem.Start = CDate(dte & " " & tme)

Sincerely, I thank you for your assistance!

LDMueller
 
Absolutely no problem at all. I don't know what I would do without your
guidance.

Thank you Sue!
 
Back
Top