PC Review


Reply
Thread Tools Rate Thread

How can I add a command button to open up a new form?

 
 
=?Utf-8?B?TWlrZQ==?=
Guest
Posts: n/a
 
      21st Apr 2005
I am extremely limited in my programming skills, but desperately need to open
up a modified version of the "Post" template up from a command button on a
modified "Contact" form. The new form also needs to be prepopulated.

I have created both new forms and saved them, but I have been unable to
figure out how to correctly setup the command button on the "Contact" form to
open up the "Post" form. I have both forms in seperate Public Folders on my
Exchange Server and in the Properties on the folder in which the modified
"Contact" form resides, I have setup the "Activities" to look for the "Post"
items in the other public folder.

I cannot seem to find the answers I am looking for in opther threads, so
please forgive me if I am being repetitive, here!

Ultimately, I need to have a command button that opens up a new form and
"passes" it a parameter (in this case the Contact or Contacts) for the new
form to be pre-populated.

If anyone knows of any sample .oft that I could model after or any resources
that I may have missed - please help!!!
 
Reply With Quote
 
 
 
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      21st Apr 2005
To create a new instance of a custom form programmatically, use the Add method on the target folder's Items collection. If it's a message form, you can use the Drafts folder as the target. If the target is a default folder, you can use the Namespace.GetDefaultFolder method to return it as a MAPIFolder object. Otherwise, you can use the code at http://www.outlookcode.com/d/code/getfolder.htm to walk the folder hierarchy and return the MAPIFolder corresponding to a given path string.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Mike" <(E-Mail Removed)> wrote in message news:41C01F40-8844-4CAF-8930-(E-Mail Removed)...
>I am extremely limited in my programming skills, but desperately need to open
> up a modified version of the "Post" template up from a command button on a
> modified "Contact" form. The new form also needs to be prepopulated.
>
> I have created both new forms and saved them, but I have been unable to
> figure out how to correctly setup the command button on the "Contact" form to
> open up the "Post" form. I have both forms in seperate Public Folders on my
> Exchange Server and in the Properties on the folder in which the modified
> "Contact" form resides, I have setup the "Activities" to look for the "Post"
> items in the other public folder.
>
> I cannot seem to find the answers I am looking for in opther threads, so
> please forgive me if I am being repetitive, here!
>
> Ultimately, I need to have a command button that opens up a new form and
> "passes" it a parameter (in this case the Contact or Contacts) for the new
> form to be pre-populated.
>
> If anyone knows of any sample .oft that I could model after or any resources
> that I may have missed - please help!!!

 
Reply With Quote
 
=?Utf-8?B?TWlrZQ==?=
Guest
Posts: n/a
 
      22nd Apr 2005
Thank you for your help! I can now open a new (different) from from a
command button, but I am still not sure how to have the form open with a
value from the original form "prepopulated."

In my case, I am opening up a new note form from a modified Contact from and
would like to have the "Contact" value in the new form filled out
automatically when the new Note form is launched from the original form - Is
this possible?

Here is my current code to open the new note form from a command button:

Sub CommandButton1_Click()
Set olns = Item.Application.GetNameSpace("MAPI")
Set MyFolder1 = olns.Folders("Public Folders")
Set MyFolder2 = MyFolder1.Folders("All Public Folders")
Set MyFolder3 = MyFolder2.Folders("Shamrock")
Set MyFolder4 = MyFolder3.Folders("General")
Set MyFolder5 = MyFolder4.Folders("Customer Notes")
Set MyItem = MyFolder5.Items.Add
MyItem.Display
End Sub

"Sue Mosher [MVP-Outlook]" wrote:

> To create a new instance of a custom form programmatically, use the Add method on the target folder's Items collection. If it's a message form, you can use the Drafts folder as the target. If the target is a default folder, you can use the Namespace.GetDefaultFolder method to return it as a MAPIFolder object. Otherwise, you can use the code at http://www.outlookcode.com/d/code/getfolder.htm to walk the folder hierarchy and return the MAPIFolder corresponding to a given path string.
>
> --
> Sue Mosher, Outlook MVP
> Author of
> Microsoft Outlook Programming - Jumpstart for
> Administrators, Power Users, and Developers
> http://www.outlookcode.com/jumpstart.aspx
>
>
> "Mike" <(E-Mail Removed)> wrote in message news:41C01F40-8844-4CAF-8930-(E-Mail Removed)...
> >I am extremely limited in my programming skills, but desperately need to open
> > up a modified version of the "Post" template up from a command button on a
> > modified "Contact" form. The new form also needs to be prepopulated.
> >
> > I have created both new forms and saved them, but I have been unable to
> > figure out how to correctly setup the command button on the "Contact" form to
> > open up the "Post" form. I have both forms in seperate Public Folders on my
> > Exchange Server and in the Properties on the folder in which the modified
> > "Contact" form resides, I have setup the "Activities" to look for the "Post"
> > items in the other public folder.
> >
> > I cannot seem to find the answers I am looking for in opther threads, so
> > please forgive me if I am being repetitive, here!
> >
> > Ultimately, I need to have a command button that opens up a new form and
> > "passes" it a parameter (in this case the Contact or Contacts) for the new
> > form to be pre-populated.
> >
> > If anyone knows of any sample .oft that I could model after or any resources
> > that I may have missed - please help!!!

>

 
Reply With Quote
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      22nd Apr 2005
MyItem.Links.Add(Item)

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Mike" <(E-Mail Removed)> wrote in message news:9D83CFF4-0E58-4F9A-88BE-(E-Mail Removed)...
> Thank you for your help! I can now open a new (different) from from a
> command button, but I am still not sure how to have the form open with a
> value from the original form "prepopulated."
>
> In my case, I am opening up a new note form from a modified Contact from and
> would like to have the "Contact" value in the new form filled out
> automatically when the new Note form is launched from the original form - Is
> this possible?
>
> Here is my current code to open the new note form from a command button:
>
> Sub CommandButton1_Click()
> Set olns = Item.Application.GetNameSpace("MAPI")
> Set MyFolder1 = olns.Folders("Public Folders")
> Set MyFolder2 = MyFolder1.Folders("All Public Folders")
> Set MyFolder3 = MyFolder2.Folders("Shamrock")
> Set MyFolder4 = MyFolder3.Folders("General")
> Set MyFolder5 = MyFolder4.Folders("Customer Notes")
> Set MyItem = MyFolder5.Items.Add
> MyItem.Display
> End Sub
>
> "Sue Mosher [MVP-Outlook]" wrote:
>
>> To create a new instance of a custom form programmatically, use the Add method on the target folder's Items collection. If it's a message form, you can use the Drafts folder as the target. If the target is a default folder, you can use the Namespace.GetDefaultFolder method to return it as a MAPIFolder object. Otherwise, you can use the code at http://www.outlookcode.com/d/code/getfolder.htm to walk the folder hierarchy and return the MAPIFolder corresponding to a given path string.


>>
>> "Mike" <(E-Mail Removed)> wrote in message news:41C01F40-8844-4CAF-8930-(E-Mail Removed)...
>> >I am extremely limited in my programming skills, but desperately need to open
>> > up a modified version of the "Post" template up from a command button on a
>> > modified "Contact" form. The new form also needs to be prepopulated.
>> >
>> > I have created both new forms and saved them, but I have been unable to
>> > figure out how to correctly setup the command button on the "Contact" form to
>> > open up the "Post" form. I have both forms in seperate Public Folders on my
>> > Exchange Server and in the Properties on the folder in which the modified
>> > "Contact" form resides, I have setup the "Activities" to look for the "Post"
>> > items in the other public folder.
>> >
>> > I cannot seem to find the answers I am looking for in opther threads, so
>> > please forgive me if I am being repetitive, here!
>> >
>> > Ultimately, I need to have a command button that opens up a new form and
>> > "passes" it a parameter (in this case the Contact or Contacts) for the new
>> > form to be pre-populated.
>> >
>> > If anyone knows of any sample .oft that I could model after or any resources
>> > that I may have missed - please help!!!

>>

 
Reply With Quote
 
=?Utf-8?B?TWlrZQ==?=
Guest
Posts: n/a
 
      22nd Apr 2005
I receive an error ("Could not complete the operation. One or more
parameters are invalid.") when I insert the code you replied with.

MyItem.Links.Add(Item)

I am assuming that "Item" in parens needs to be replaced with a valid object
name - but which one? Do I place the field name that I am pulling from or
the destination location? Do they need to be named the same on both forms?

I would like to pass the value from the "FullName" field of the modified
Contact form to a "Contacts..." field setup on the new custom form the
command button is opening - Here is what I have:

Sub CommandButton1_Click()

Set olns = Item.Application.GetNameSpace("MAPI")
Set MyFolder1 = olns.Folders("Public Folders")
Set MyFolder2 = MyFolder1.Folders("All Public Folders")
Set MyFolder3 = MyFolder2.Folders("Shamrock")
Set MyFolder4 = MyFolder3.Folders("General")
Set MyFolder5 = MyFolder4.Folders("Customer Notes")
Set MyItem = MyFolder5.Items.Add
MyItem.Links.Add(FullName)
MyItem.Display
End Sub


"Sue Mosher [MVP-Outlook]" wrote:

> MyItem.Links.Add(Item)
>
> --
> Sue Mosher, Outlook MVP
> Author of
> Microsoft Outlook Programming - Jumpstart for
> Administrators, Power Users, and Developers
> http://www.outlookcode.com/jumpstart.aspx
>
>
> "Mike" <(E-Mail Removed)> wrote in message news:9D83CFF4-0E58-4F9A-88BE-(E-Mail Removed)...
> > Thank you for your help! I can now open a new (different) from from a
> > command button, but I am still not sure how to have the form open with a
> > value from the original form "prepopulated."
> >
> > In my case, I am opening up a new note form from a modified Contact from and
> > would like to have the "Contact" value in the new form filled out
> > automatically when the new Note form is launched from the original form - Is
> > this possible?
> >
> > Here is my current code to open the new note form from a command button:
> >
> > Sub CommandButton1_Click()
> > Set olns = Item.Application.GetNameSpace("MAPI")
> > Set MyFolder1 = olns.Folders("Public Folders")
> > Set MyFolder2 = MyFolder1.Folders("All Public Folders")
> > Set MyFolder3 = MyFolder2.Folders("Shamrock")
> > Set MyFolder4 = MyFolder3.Folders("General")
> > Set MyFolder5 = MyFolder4.Folders("Customer Notes")
> > Set MyItem = MyFolder5.Items.Add
> > MyItem.Display
> > End Sub
> >
> > "Sue Mosher [MVP-Outlook]" wrote:
> >
> >> To create a new instance of a custom form programmatically, use the Add method on the target folder's Items collection. If it's a message form, you can use the Drafts folder as the target. If the target is a default folder, you can use the Namespace.GetDefaultFolder method to return it as a MAPIFolder object. Otherwise, you can use the code at http://www.outlookcode.com/d/code/getfolder.htm to walk the folder hierarchy and return the MAPIFolder corresponding to a given path string.

>
> >>
> >> "Mike" <(E-Mail Removed)> wrote in message news:41C01F40-8844-4CAF-8930-(E-Mail Removed)...
> >> >I am extremely limited in my programming skills, but desperately need to open
> >> > up a modified version of the "Post" template up from a command button on a
> >> > modified "Contact" form. The new form also needs to be prepopulated.
> >> >
> >> > I have created both new forms and saved them, but I have been unable to
> >> > figure out how to correctly setup the command button on the "Contact" form to
> >> > open up the "Post" form. I have both forms in seperate Public Folders on my
> >> > Exchange Server and in the Properties on the folder in which the modified
> >> > "Contact" form resides, I have setup the "Activities" to look for the "Post"
> >> > items in the other public folder.
> >> >
> >> > I cannot seem to find the answers I am looking for in opther threads, so
> >> > please forgive me if I am being repetitive, here!
> >> >
> >> > Ultimately, I need to have a command button that opens up a new form and
> >> > "passes" it a parameter (in this case the Contact or Contacts) for the new
> >> > form to be pre-populated.
> >> >
> >> > If anyone knows of any sample .oft that I could model after or any resources
> >> > that I may have missed - please help!!!
> >>

>

 
Reply With Quote
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      22nd Apr 2005
If, as your message implied, Item *is* a valid object. The intrinsic Item object represents the item where the code is running. This contact item needs to be saved before you can add it as a link to some other item. Does your scenario include launching the other form before the contact is saved? If so, add an Item.Save statement before you invoke the Links collection.

When you step through the code with the script debugger, which particular statement triggers the error you cited?

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Mike" <(E-Mail Removed)> wrote in message news:1F30730D-22CF-41BE-AD0F-(E-Mail Removed)...
>I receive an error ("Could not complete the operation. One or more
> parameters are invalid.") when I insert the code you replied with.
>
> MyItem.Links.Add(Item)
>
> I am assuming that "Item" in parens needs to be replaced with a valid object
> name - but which one? Do I place the field name that I am pulling from or
> the destination location? Do they need to be named the same on both forms?
>
> I would like to pass the value from the "FullName" field of the modified
> Contact form to a "Contacts..." field setup on the new custom form the
> command button is opening - Here is what I have:
>
> Sub CommandButton1_Click()
>
> Set olns = Item.Application.GetNameSpace("MAPI")
> Set MyFolder1 = olns.Folders("Public Folders")
> Set MyFolder2 = MyFolder1.Folders("All Public Folders")
> Set MyFolder3 = MyFolder2.Folders("Shamrock")
> Set MyFolder4 = MyFolder3.Folders("General")
> Set MyFolder5 = MyFolder4.Folders("Customer Notes")
> Set MyItem = MyFolder5.Items.Add
> MyItem.Links.Add(FullName)
> MyItem.Display
> End Sub
>
>
> "Sue Mosher [MVP-Outlook]" wrote:
>
>> MyItem.Links.Add(Item)


>>
>> "Mike" <(E-Mail Removed)> wrote in message news:9D83CFF4-0E58-4F9A-88BE-(E-Mail Removed)...
>> > Thank you for your help! I can now open a new (different) from from a
>> > command button, but I am still not sure how to have the form open with a
>> > value from the original form "prepopulated."
>> >
>> > In my case, I am opening up a new note form from a modified Contact from and
>> > would like to have the "Contact" value in the new form filled out
>> > automatically when the new Note form is launched from the original form - Is
>> > this possible?
>> >
>> > Here is my current code to open the new note form from a command button:
>> >
>> > Sub CommandButton1_Click()
>> > Set olns = Item.Application.GetNameSpace("MAPI")
>> > Set MyFolder1 = olns.Folders("Public Folders")
>> > Set MyFolder2 = MyFolder1.Folders("All Public Folders")
>> > Set MyFolder3 = MyFolder2.Folders("Shamrock")
>> > Set MyFolder4 = MyFolder3.Folders("General")
>> > Set MyFolder5 = MyFolder4.Folders("Customer Notes")
>> > Set MyItem = MyFolder5.Items.Add
>> > MyItem.Display
>> > End Sub
>> >
>> > "Sue Mosher [MVP-Outlook]" wrote:
>> >
>> >> To create a new instance of a custom form programmatically, use the Add method on the target folder's Items collection. If it's a message form, you can use the Drafts folder as the target. If the target is a default folder, you can use the Namespace.GetDefaultFolder method to return it as a MAPIFolder object. Otherwise, you can use the code at http://www.outlookcode.com/d/code/getfolder.htm to walk the folder hierarchy and return the MAPIFolder corresponding to a given path string.

>>
>> >>
>> >> "Mike" <(E-Mail Removed)> wrote in message news:41C01F40-8844-4CAF-8930-(E-Mail Removed)...
>> >> >I am extremely limited in my programming skills, but desperately need to open
>> >> > up a modified version of the "Post" template up from a command button on a
>> >> > modified "Contact" form. The new form also needs to be prepopulated.
>> >> >
>> >> > I have created both new forms and saved them, but I have been unable to
>> >> > figure out how to correctly setup the command button on the "Contact" form to
>> >> > open up the "Post" form. I have both forms in seperate Public Folders on my
>> >> > Exchange Server and in the Properties on the folder in which the modified
>> >> > "Contact" form resides, I have setup the "Activities" to look for the "Post"
>> >> > items in the other public folder.
>> >> >
>> >> > Ultimately, I need to have a command button that opens up a new form and
>> >> > "passes" it a parameter (in this case the Contact or Contacts) for the new
>> >> > form to be pre-populated.


 
Reply With Quote
 
=?Utf-8?B?TWlrZQ==?=
Guest
Posts: n/a
 
      25th Apr 2005
Sue,

Thank you so much for all of your help! Here is section of code that
crashes in the script editor:

MyItem.Links.Add(FullName)


"Sue Mosher [MVP-Outlook]" wrote:

> If, as your message implied, Item *is* a valid object. The intrinsic Item object represents the item where the code is running. This contact item needs to be saved before you can add it as a link to some other item. Does your scenario include launching the other form before the contact is saved? If so, add an Item.Save statement before you invoke the Links collection.
>
> When you step through the code with the script debugger, which particular statement triggers the error you cited?
>
> --
> Sue Mosher, Outlook MVP
> Author of
> Microsoft Outlook Programming - Jumpstart for
> Administrators, Power Users, and Developers
> http://www.outlookcode.com/jumpstart.aspx
>
>
> "Mike" <(E-Mail Removed)> wrote in message news:1F30730D-22CF-41BE-AD0F-(E-Mail Removed)...
> >I receive an error ("Could not complete the operation. One or more
> > parameters are invalid.") when I insert the code you replied with.
> >
> > MyItem.Links.Add(Item)
> >
> > I am assuming that "Item" in parens needs to be replaced with a valid object
> > name - but which one? Do I place the field name that I am pulling from or
> > the destination location? Do they need to be named the same on both forms?
> >
> > I would like to pass the value from the "FullName" field of the modified
> > Contact form to a "Contacts..." field setup on the new custom form the
> > command button is opening - Here is what I have:
> >
> > Sub CommandButton1_Click()
> >
> > Set olns = Item.Application.GetNameSpace("MAPI")
> > Set MyFolder1 = olns.Folders("Public Folders")
> > Set MyFolder2 = MyFolder1.Folders("All Public Folders")
> > Set MyFolder3 = MyFolder2.Folders("Shamrock")
> > Set MyFolder4 = MyFolder3.Folders("General")
> > Set MyFolder5 = MyFolder4.Folders("Customer Notes")
> > Set MyItem = MyFolder5.Items.Add
> > MyItem.Links.Add(FullName)
> > MyItem.Display
> > End Sub
> >
> >
> > "Sue Mosher [MVP-Outlook]" wrote:
> >
> >> MyItem.Links.Add(Item)

>
> >>
> >> "Mike" <(E-Mail Removed)> wrote in message news:9D83CFF4-0E58-4F9A-88BE-(E-Mail Removed)...
> >> > Thank you for your help! I can now open a new (different) from from a
> >> > command button, but I am still not sure how to have the form open with a
> >> > value from the original form "prepopulated."
> >> >
> >> > In my case, I am opening up a new note form from a modified Contact from and
> >> > would like to have the "Contact" value in the new form filled out
> >> > automatically when the new Note form is launched from the original form - Is
> >> > this possible?
> >> >
> >> > Here is my current code to open the new note form from a command button:
> >> >
> >> > Sub CommandButton1_Click()
> >> > Set olns = Item.Application.GetNameSpace("MAPI")
> >> > Set MyFolder1 = olns.Folders("Public Folders")
> >> > Set MyFolder2 = MyFolder1.Folders("All Public Folders")
> >> > Set MyFolder3 = MyFolder2.Folders("Shamrock")
> >> > Set MyFolder4 = MyFolder3.Folders("General")
> >> > Set MyFolder5 = MyFolder4.Folders("Customer Notes")
> >> > Set MyItem = MyFolder5.Items.Add
> >> > MyItem.Display
> >> > End Sub
> >> >
> >> > "Sue Mosher [MVP-Outlook]" wrote:
> >> >
> >> >> To create a new instance of a custom form programmatically, use the Add method on the target folder's Items collection. If it's a message form, you can use the Drafts folder as the target. If the target is a default folder, you can use the Namespace.GetDefaultFolder method to return it as a MAPIFolder object. Otherwise, you can use the code at http://www.outlookcode.com/d/code/getfolder.htm to walk the folder hierarchy and return the MAPIFolder corresponding to a given path string.
> >>
> >> >>
> >> >> "Mike" <(E-Mail Removed)> wrote in message news:41C01F40-8844-4CAF-8930-(E-Mail Removed)...
> >> >> >I am extremely limited in my programming skills, but desperately need to open
> >> >> > up a modified version of the "Post" template up from a command button on a
> >> >> > modified "Contact" form. The new form also needs to be prepopulated.
> >> >> >
> >> >> > I have created both new forms and saved them, but I have been unable to
> >> >> > figure out how to correctly setup the command button on the "Contact" form to
> >> >> > open up the "Post" form. I have both forms in seperate Public Folders on my
> >> >> > Exchange Server and in the Properties on the folder in which the modified
> >> >> > "Contact" form resides, I have setup the "Activities" to look for the "Post"
> >> >> > items in the other public folder.
> >> >> >
> >> >> > Ultimately, I need to have a command button that opens up a new form and
> >> >> > "passes" it a parameter (in this case the Contact or Contacts) for the new
> >> >> > form to be pre-populated.

>
>

 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      26th Apr 2005
Any Link you add must be a ContactItem. A string value will error. In the
Object Browser it lists the argument for Add as an Object.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Mike" <(E-Mail Removed)> wrote in message
news:11C98E26-4648-49BD-A7AC-(E-Mail Removed)...
> Sue,
>
> Thank you so much for all of your help! Here is section of code that
> crashes in the script editor:
>
> MyItem.Links.Add(FullName)


 
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
Command Button>Form Operation> Open Form...also need find function =?Utf-8?B?YTQyMHA=?= Microsoft Access 1 5th Aug 2007 05:35 AM
Main Form/Subform/Command Button to Open Another Form =?Utf-8?B?THVjaWxsZQ==?= Microsoft Access Forms 3 2nd Aug 2007 07:36 AM
Form/Subform/Command Button to Open Form - Type Mismatch Error =?Utf-8?B?U2hhcm9u?= Microsoft Access Form Coding 2 12th Jul 2007 10:02 PM
save current form and open another form using a single command button? moe leaer via AccessMonster.com Microsoft Access Forms 3 26th May 2005 04:44 PM
Problem adding a command button to a form in order to open another form =?Utf-8?B?SmFuaWNl?= Microsoft Access Getting Started 2 10th May 2004 11:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:08 PM.