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
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?

Signature
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
>I receive an error ("Could not complete the operation. One or more
> parameters are invalid.") when I insert the code you replied with.
[quoted text clipped - 24 lines]
>
>> MyItem.Links.Add(Item)
>> > 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
[quoted text clipped - 34 lines]
>> >> > "passes" it a parameter (in this case the Contact or Contacts) for the new
>> >> > form to be pre-populated.
Mike - 25 Apr 2005 14:13 GMT
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)
> 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.
>
[quoted text clipped - 67 lines]
> >> >> > "passes" it a parameter (in this case the Contact or Contacts) for the new
> >> >> > form to be pre-populated.
Ken Slovak - [MVP - Outlook] - 26 Apr 2005 14:28 GMT
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.

Signature
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
> 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)