How do I grab a field property (like .value) so I can modify it via OL code?

  • Thread starter cmonroe21 via OfficeKB.com
  • Start date
C

cmonroe21 via OfficeKB.com

I am creating a custom OL2007 task form with coding in Outlook. I saw the
outlookcode.com page "Syntax for outlook property and form control values and
events" and got the PropertyChange fucntion to work with a case statement
(see first two lines of case statement). But when I want to change the value
of the field that I want to it doesn't work. A little background, I have a
text box named txtTestBox bound to a user-defined field "TestBox". I know my
function and case statement works, but how do I grab my user-defined field to
manipulate it like I could the message box and the task.subject? I tried
SEVERAL different syntaxes, as you can see below, but I think it's obvious
I'm clueless. (Note-- I thought I would use the PropertyChange function
rather than the CustomPropertyChange because I did not create a custom
property... I created a custom field but not a custom property... but it will
only work with CustomPropertyChange??) (And yes, I only try the lines in the
case statements one at a time.)
Any input??


Sub Item_CustomPropertyChange(ByVal Name)
on error resume next
Select Case Name
Case "Field1"
'MsgBox "You changed Field1" 'works
'Item.subject = "Works!" 'works
'Item.TestBox.text = "works!" 'doesn't work??
'Item.TestBox.value= "works!" 'doesn't work??
'TestBox.text = "works!" 'doesn't work??
'TestBox.value = "works!" 'doesn't work??
'Item.TestBox = "works!" 'doesn't work??
'TestBox = "works!" 'doesn't work??
End Select
End Sub
 
S

Sue Mosher [MVP]

A custom field and a custom property are the same thing. "Field" is a
synonym for "property" in the Outlook code context. If you go back to the
page you cited, at http://www.outlookcode.com/article.aspx?ID=38, the
section on custom properties shows how to access custom field/property
values. It also shows how to work with unbound controls, in case you have
some of those, too.
 
C

cmonroe21 via OfficeKB.com

Thank you! Item.UserProperties("TestBox").Value = "works!" worked!!

I thought that TestBox was a field that had properties, but was not a
property itself... obviously my train of thought was not correct! Got my
head wires crossed! Thank you for your help!
A custom field and a custom property are the same thing. "Field" is a
synonym for "property" in the Outlook code context. If you go back to the
page you cited, at http://www.outlookcode.com/article.aspx?ID=38, the
section on custom properties shows how to access custom field/property
values. It also shows how to work with unbound controls, in case you have
some of those, too.
I am creating a custom OL2007 task form with coding in Outlook. I saw the
outlookcode.com page "Syntax for outlook property and form control values
[quoted text clipped - 33 lines]
End Select
End Sub
 
S

Sue Mosher [MVP]

No, your first instinct was correct. A look at the object browser (F2 in
VBA) would show you that the UserProperty object itself has properties, such
as the Value property in your code snippet.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


cmonroe21 via OfficeKB.com said:
Thank you! Item.UserProperties("TestBox").Value = "works!" worked!!

I thought that TestBox was a field that had properties, but was not a
property itself... obviously my train of thought was not correct! Got my
head wires crossed! Thank you for your help!
A custom field and a custom property are the same thing. "Field" is a
synonym for "property" in the Outlook code context. If you go back to the
page you cited, at http://www.outlookcode.com/article.aspx?ID=38, the
section on custom properties shows how to access custom field/property
values. It also shows how to work with unbound controls, in case you have
some of those, too.
I am creating a custom OL2007 task form with coding in Outlook. I saw
the
outlookcode.com page "Syntax for outlook property and form control
values
[quoted text clipped - 33 lines]
End Select
End Sub
 
C

cmonroe21 via OfficeKB.com

Thank you Sue. I think you are my new hero :)
No, your first instinct was correct. A look at the object browser (F2 in
VBA) would show you that the UserProperty object itself has properties, such
as the Value property in your code snippet.
Thank you! Item.UserProperties("TestBox").Value = "works!" worked!!
[quoted text clipped - 16 lines]
 

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