link.item

P

Paul Martin

Hi All

I have made a custom Task form and setup the registry so when you select
contact then new task for contact I get the custom form. I am trying to get
my head around the next bit. How to get a few fields automatically filled in
e.g. name, company, telephone etc. I think I can use link.item comands but
not sure how to go about it. Can anybody give me some suggestions.

Thanks
Paul
 
S

Sue Mosher [MVP-Outlook]

In the Item_Open event handler, you can return the ContactItem represented
by the first link with the expression Item.Links(1).Item. Once you ahve
that, do whatever you like with its data.
 
P

Paul Martin

Hi Sue
In the Item_Open event handler, you can return the ContactItem represented
by the first link with the expression Item.Links(1).Item. Once you ahve
that, do whatever you like with its data.

Thanks for the speedy reply. I have been reading your book and trying to
figure out how to do what you suggest . But I can't seem to get my head
around how to achieve what I want. I wonder if you could get me started. If
I wanted to get the FULLNAME from the contact I have just selected the
ACTION NEW TASK FOR CONTACT what would the coding look like? ...and if I
wanted to display this on the custom TASK FORM I have created.


Thanks
Paul
 
S

Sue Mosher [MVP-Outlook]

Function Item_Open()
If Item.Links.Count = 1 Then
Set objContact = Item.Links(1).Item
MsgBox objContact.FullName
End If
End Function

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
P

Paul Martin

Hi Sue

Superb - thanks for that.

I can see how to get the particular fields I need e.g. Full Name, Company
address, etc but how do I get the fields I have created to be populated with
this information? E.g if I have created a field to Show the fullname how do
I fill it with the Fullname linked to the particular contact?

Its starting all to make sense

THanks
Paul
 
P

Paul Martin

Hi Sue

Think I am getting there but not sure in the right direction. I have found a
way to populate fields if I make them LISTBOXES and use the following code
Function Item_Open()

If Item.Links.Count = 1 Then

Set objContact = Item.Links(1).Item

Set Formpage = Item.GetInspector.ModifiedFormPages("Fantasy JOB")

Set Control = FormPage.Controls("CustomerContact")

Control.PossibleValues = objContact.FullName

End If

End Function

This works great for FULLNAME but I can't seem to get COMPANY NAME, ADDRESS,
TELEPHONE or EMAIL to work. I tried simply changing the FULLNAME to these
values to make sure I get the correct information but I just get errors.
What am I doing wrong?

Cheers

Paul
 
P

Paul Martin

Hi Sue

Found my problem. I am not using the correct LINK fields. Solved EMAIL now
looking for the Business Telephone and Address FIELD titles. Is there anyway
of seeing what these are? At the moment I am searching websites (yours
mainly1) for their names.

Thanks
Paul
 
P

Paul Martin

Hi Sue

Success and not ;)

I got all the fields to work and now I can get exactly what I want problem
is I was using the same contact all the time to test form. But if I select a
different contact and ACTION NEW TASK FOR CONTACT none of the fields are
filled in. Can you have a look and see what I have done wrong. Going back to
the original contact and form works great.
Function Item_Open()

If Item.Links.Count = 1 Then

Set Formpage = Item.GetInspector.ModifiedFormPages("Fantasy JOB")

Set objContact = Item.Links(1).Item

Set objInsp = Item.GetInspector

Set Control = FormPage.Controls("CustomerContact")

Control.PossibleValues = objContact.FullName

Set Control2 = FormPage.Controls("Email")

Control2.PossibleValues = objContact.IMAddress

Set Control3 = FormPage.Controls("Telephone")

Control3.PossibleValues = objContact.BusinessTelephoneNumber

Set Control4 = FormPage.Controls("Street")

Control4.PossibleValues = objContact.BusinessAddressStreet

Set Control5 = FormPage.Controls("Company")

Control5.PossibleValues = objContact.CompanyName

Set Control6 = FormPage.Controls("Town")

Control6.PossibleValues = objContact.BusinessAddressCity

Set Control7 = FormPage.Controls("County")

Control7.PossibleValues = objContact.BusinessAddressState

Set Control8 = FormPage.Controls("Postcode")

Control8.PossibleValues = objContact.BusinessAddressPostalCode

End If

End Function
 
S

Sue Mosher [MVP-Outlook]

No, that won't work. Use:

Item.UserProperties("propname") = "some value"

See http://www.outlookcode.com/d/propsyntax.htm for more Outlook form syntax
basics.

When in doubt about the exact name of a property, check the object browser:
Press ALt+F11 to open the VBA environment in Outlook, then press F2. Switch
from <All Libraries> to Outlook to browse all Outlook objects and their
properties, methods, and events. Select any object or member, then press F1
to see its Help topic.
 
P

Paul Martin

Hi Sue

Thanks for that. Redid form and worked great but still hit a problem
mentioned below. If I test the form on a contact I get the fields filled in
no problem. But as soon as I try another contact I still get the custom form
but the fields not filled in.

Below is the code I have now used on the form. Is there a bit missing?
Function Item_Open()

If Item.Links.Count = 1 Then

Set objContact = Item.Links(1).Item

Set Formpage = Item.GetInspector.ModifiedFormPages("Fantasy JOB")

Item.UserProperties("CustomerContact") = objContact.FullName

Item.UserProperties("Telephone") = objContact.BusinessTelephoneNumber

Item.UserProperties("Email") = objContact.Email1Address

Item.UserProperties("CompanyName") = objContact.CompanyName

Item.UserProperties("AddressStreet") = objContact.BusinessAddressStreet

Item.UserProperties("AddressCity") = objContact.BusinessAddressCity

Item.UserProperties("AddressState") = objContact.BusinessAddressState

Item.UserProperties("AddressPostCode") =
objContact.BusinessAddressPostalCode

End If

End Function



Cheers

Paul
 
P

Paul Martin

Hi Sue

If I remove

If Item.Links.Count = 1 Then
End If

I always get the test contacts details filled in on the task if I select NEW
TASK FOR CONTACT using any other contact.

If I add these lines back in get correct details for test contact but blank
for all other contacts.

Hope helps
Paul
 
P

Paul Martin

Hi Sue

Stopped working again :( Now no contact fills in the form Its like the form
when created from the NEW TASK FOR CONTACT has a setting preventing it
linking to the contact and therefore no fields filling in?

Paul
 
P

Paul Martin

Hi Sue

SOlved the problem. It was staring me in the face. WHat I must have been
doing is trying the new task for contact. When the task appeared for the
contact selecting design this form and then resaving. There must be link
info saved with the form so it no longer links again.

Thanks for help

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top