FileAs Custom Property

C

Cass

I am creating a custom form with custom fields in outlook 2003.

The form that I am creating is a custom contact form. I want each
customer thats listed in this contact folder to be filed by the custom
fields that I created, Utility & CityState.

To do this i've tried adding the following formula to the form code:

Sub Item_FileAs
Item.FileAs = Item.Utility &vbcrlf " (" & Item.CityState & ")"
End Sub

To Display...
"Utilty
City State"
....In the gray area for the File As.

When I try to run the form, the form displayes this "9/21/2007 8:00:00
AM". Can someone help me figure out what's going on.
 
S

Sue Mosher [MVP-Outlook]

Lots of problems here:

1) There is no FileAs event. You should use the Item_Write event handler.

2) There is no Utility standard property. Access custom properties through the UserProperties collection.

3) There is no CityState standard property. When in doubt, 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.

4) You don't need the parentheses in the Item.FileAs statement . Try:

Item.FileAs = Item.UserProperties("Utility") & vbcrlf & _
Item.City & " " & Item.State
 
C

Cass

Lots of problems here:

1) There is no FileAs event. You should use the Item_Write event handler.

2) There is no Utility standard property. Access custom properties through the UserProperties collection.

3) There is no CityState standard property. When in doubt, 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.

4) You don't need the parentheses in the Item.FileAs statement . Try:

Item.FileAs = Item.UserProperties("Utility") & vbcrlf & _
Item.City & " " & Item.State

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










- Show quoted text -

Ok so I tried:

Function Item_Write()
Item.FileAs = Item.UserProperties("Utility") & vbcrlf & _
Item.UserProperties("CityState")
End Function

It took away the date and displayed " ()" in the text box. However now
when I type into the Utility and CityState fields, the FileAs text box
doesn't update with the information
 
C

Cass

Ok so I tried:

Function Item_Write()
Item.FileAs = Item.UserProperties("Utility") & vbcrlf & _
Item.UserProperties("CityState")
End Function

It took away the date and displayed " ()" in the text box. However now
when I type into the Utility and CityState fields, the FileAs text box
doesn't update with the information- Hide quoted text -

- Show quoted text -

And just to be clear the fields are created and inside the form. They
are displayed in the "User-Defined Fields in Folder" folder and my
forms folder
 
S

Sue Mosher [MVP-Outlook]

And just to be clear the fields are created and inside the form. They
are displayed in the "User-Defined Fields in Folder" folder and my
forms folder

Where they need to be present is in User-Defined Fields in This Item.
when I type into the Utility and CityState fields, the FileAs text box
doesn't update with the information

Code for the Item_Write event handler runs when you save the item. If you want the FileAs value to update when you type, that requires different events -- PropertyChange and CustomPropertyChange. See http://www.outlookcode.com/article.aspx?ID=38
 
C

Cass

Where they need to be present is in User-Defined Fields in This Item.


Code for the Item_Write event handler runs when you save the item. If you want the FileAs value to update when you type, that requires different events -- PropertyChange and CustomPropertyChange. Seehttp://www.outlookcode.com/article.aspx?ID=38

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








- Show quoted text -

Thanks so much for your help so far...

You'll have to excuse me but that code throws me completely off...
From this:
Sub Item_CustomPropertyChange(ByVal Name)
Select Case Name
Case "MyProp1"
strMyProp1 = Item.UserProperties("MyProp1")
Select Case strMyProp1
Case "Text1"
' code to react to the MyProp1
' string property having a value of "Text1"
Case "Text2"
' code to react to the MyProp1
' string property having a value of "Text2"
Case Else
' code to handle other values of MyProp1
End Select
Case "MyProp2"
' code to handle a change in MyProp2 goes here

' continue with Case statements for other properties
' whose values you want to monitor
End Select
End Sub



I interpretted this by putting some other codes together that i'd
found:
Sub Item_CustomPropertyChange(FileAs)
Select Case Name
Case "Utility"
strUtility=Item.UserProperties("Utilities")
Select Case strUtility
Case "Text1"
If Item.UserProperties.Find("Utility") <> "" Then
If Item.UserProperties.Find("Utility") <> "" Then
Item.UserProperties.Find("Utility") & " (" &
Item.UserProperties.Find("Utility") & ")"
Else
Item.FileAs = Item.UserProperties.Find("Utility")
End If
Else
Item.FileAs = Item.UserProperties.Find("Utility")
End If
End Select
EndSub

Function Item_Write()
Item.FileAs = Item.UserProperties.Find("Utility") & vbcrlf & _
Item.UserProperties.Find("CityState")
End Function






And don't get me started on the PropertyChange code. I know this is
not right, not only because it didn't work but because I have no idea
how to code this. Could you help me to figure this out? Thanks!
 
C

Cass

Where they need to be present is in User-Defined Fields in This Item.
Code for the Item_Write event handler runs when you save the item. If you want the FileAs value to update when you type, that requires different events -- PropertyChange and CustomPropertyChange. Seehttp://www.outlookcode.com/article.aspx?ID=38
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Cass said:
On Sep 21, 1:37 pm, "Sue Mosher [MVP-Outlook]"
Lots of problems here:
1) There is no FileAs event. You should use the Item_Write event handler.
2) There is no Utility standard property. Access custom properties through the UserProperties collection.
3) There is no CityState standard property. When in doubt, 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.
4) You don't need the parentheses in the Item.FileAs statement . Try:
Item.FileAs = Item.UserProperties("Utility") & vbcrlf & _
Item.City & " " & Item.State
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
I am creating a custom form with custom fields in outlook 2003.
The form that I am creating is a custom contact form. I want each
customer thats listed in this contact folder to be filed by the custom
fields that I created, Utility & CityState.
To do this i've tried adding the following formula to the form code:
Sub Item_FileAs
Item.FileAs = Item.Utility &vbcrlf " (" & Item.CityState & ")"
End Sub
To Display...
"Utilty
City State"
...In the gray area for the File As.
When I try to run the form, the form displayes this "9/21/2007 8:00:00
AM". Can someone help me figure out what's going on.- Hide quoted text -
- Show quoted text -
Ok so I tried:
Function Item_Write()
Item.FileAs = Item.UserProperties("Utility") & vbcrlf & _
Item.UserProperties("CityState")
End Function
It took away the date and displayed " ()" in the text box. However now
when I type into the Utility and CityState fields, the FileAs text box
doesn't update with the information- Hide quoted text -
- Show quoted text -

Thanks so much for your help so far...

You'll have to excuse me but that code throws me completely off...
From this:

Sub Item_CustomPropertyChange(ByVal Name)
Select Case Name
Case "MyProp1"
strMyProp1 = Item.UserProperties("MyProp1")
Select Case strMyProp1
Case "Text1"
' code to react to the MyProp1
' string property having a value of "Text1"
Case "Text2"
' code to react to the MyProp1
' string property having a value of "Text2"
Case Else
' code to handle other values of MyProp1
End Select
Case "MyProp2"
' code to handle a change in MyProp2 goes here

' continue with Case statements for other properties
' whose values you want to monitor
End Select
End Sub

I interpretted this by putting some other codes together that i'd
found:
Sub Item_CustomPropertyChange(FileAs)
Select Case Name
Case "Utility"
strUtility=Item.UserProperties("Utilities")
Select Case strUtility
Case "Text1"
If Item.UserProperties.Find("Utility") <> "" Then
If Item.UserProperties.Find("Utility") <> "" Then
Item.UserProperties.Find("Utility") & " (" &
Item.UserProperties.Find("Utility") & ")"
Else
Item.FileAs = Item.UserProperties.Find("Utility")
End If
Else
Item.FileAs = Item.UserProperties.Find("Utility")
End If
End Select
EndSub

Function Item_Write()
Item.FileAs = Item.UserProperties.Find("Utility") & vbcrlf & _
Item.UserProperties.Find("CityState")
End Function

And don't get me started on the PropertyChange code. I know this is
not right, not only because it didn't work but because I have no idea
how to code this. Could you help me to figure this out? Thanks!- Hide quoted text -

- Show quoted text -

Nevermind. After thinking a bit I realized they don't really need to
see the FileAsField. Thanks SO much for your help!
 
S

Sue Mosher [MVP-Outlook]

What in particular throws you off? I've made your code more readable and annotated the obvious problems:

Sub Item_CustomPropertyChange(FileAs)
' #1: Never change the event procedure signature.
' Leave the parameter as Name, so that it matches
' the Select Case statement.
Select Case Name
Case "Utility"
' #3: If the name of the property that changes is Utility,
' why is this statement using "Utilities". You must
' use property names consistently.
strUtility=Item.UserProperties("Utilities")
Select Case strUtility
Case "Text1"
' #4: You have the same If ... Then expression twice.
If Item.UserProperties.Find("Utility") <> "" Then
If Item.UserProperties.Find("Utility") <> "" Then
' #5: The next statement is an expression, not a complete code
' statement. I'm not sure what you were trying to do with it.
Item.UserProperties.Find("Utility") & " (" & Item.UserProperties.Find("Utility") & ")"
Else
Item.FileAs = Item.UserProperties.Find("Utility")
End If
Else
Item.FileAs = Item.UserProperties.Find("Utility")
End If
End Select
End Sub

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


Cass said:
And just to be clear the fields are created and inside the form. They
are displayed in the "User-Defined Fields in Folder" folder and my
forms folder

Where they need to be present is in User-Defined Fields in This Item.
when I type into the Utility and CityState fields, the FileAs text box
doesn't update with the information

Code for the Item_Write event handler runs when you save the item. If you want the FileAs value to update when you type, that requires different events -- PropertyChange and CustomPropertyChange. Seehttp://www.outlookcode.com/article.aspx?ID=38

Cass said:
On Sep 21, 1:37 pm, "Sue Mosher [MVP-Outlook]"
Lots of problems here:
1) There is no FileAs event. You should use the Item_Write event handler.
2) There is no Utility standard property. Access custom properties through the UserProperties collection.
3) There is no CityState standard property. When in doubt, 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.
4) You don't need the parentheses in the Item.FileAs statement . Try:
Item.FileAs = Item.UserProperties("Utility") & vbcrlf & _
Item.City & " " & Item.State
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
I am creating a custom form with custom fields in outlook 2003.
The form that I am creating is a custom contact form. I want each
customer thats listed in this contact folder to be filed by the custom
fields that I created, Utility & CityState.
To do this i've tried adding the following formula to the form code:
Sub Item_FileAs
Item.FileAs = Item.Utility &vbcrlf " (" & Item.CityState & ")"
End Sub
To Display...
"Utilty
City State"
...In the gray area for the File As.
When I try to run the form, the form displayes this "9/21/2007 8:00:00
AM". Can someone help me figure out what's going on.- Hide quoted text -
- Show quoted text -
Ok so I tried:
Function Item_Write()
Item.FileAs = Item.UserProperties("Utility") & vbcrlf & _
Item.UserProperties("CityState")
End Function
It took away the date and displayed " ()" in the text box. However now
when I type into the Utility and CityState fields, the FileAs text box
doesn't update with the information- Hide quoted text -

- Show quoted text -

Thanks so much for your help so far...

You'll have to excuse me but that code throws me completely off...
From this:
Sub Item_CustomPropertyChange(ByVal Name)
Select Case Name
Case "MyProp1"
strMyProp1 = Item.UserProperties("MyProp1")
Select Case strMyProp1
Case "Text1"
' code to react to the MyProp1
' string property having a value of "Text1"
Case "Text2"
' code to react to the MyProp1
' string property having a value of "Text2"
Case Else
' code to handle other values of MyProp1
End Select
Case "MyProp2"
' code to handle a change in MyProp2 goes here

' continue with Case statements for other properties
' whose values you want to monitor
End Select
End Sub



I interpretted this by putting some other codes together that i'd
found:
Sub Item_CustomPropertyChange(FileAs)
Select Case Name
Case "Utility"
strUtility=Item.UserProperties("Utilities")
Select Case strUtility
Case "Text1"
If Item.UserProperties.Find("Utility") <> "" Then
If Item.UserProperties.Find("Utility") <> "" Then
Item.UserProperties.Find("Utility") & " (" &
Item.UserProperties.Find("Utility") & ")"
Else
Item.FileAs = Item.UserProperties.Find("Utility")
End If
Else
Item.FileAs = Item.UserProperties.Find("Utility")
End If
End Select
EndSub

Function Item_Write()
Item.FileAs = Item.UserProperties.Find("Utility") & vbcrlf & _
Item.UserProperties.Find("CityState")
End Function






And don't get me started on the PropertyChange code. I know this is
not right, not only because it didn't work but because I have no idea
how to code this. Could you help me to figure this out? Thanks!
 
C

Cass

What in particular throws you off? I've made your code more readable and annotated the obvious problems:

Sub Item_CustomPropertyChange(FileAs)
' #1: Never change the event procedure signature.
' Leave the parameter as Name, so that it matches
' the Select Case statement.
Select Case Name
Case "Utility"
' #3: If the name of the property that changes is Utility,
' why is this statement using "Utilities". You must
' use property names consistently.
strUtility=Item.UserProperties("Utilities")
Select Case strUtility
Case "Text1"
' #4: You have the same If ... Then expression twice.
If Item.UserProperties.Find("Utility") <> "" Then
If Item.UserProperties.Find("Utility") <> "" Then
' #5: The next statement is an expression, not a complete code
' statement. I'm not sure what you were trying to do with it.
Item.UserProperties.Find("Utility") & " (" & Item.UserProperties.Find("Utility") & ")"
Else
Item.FileAs = Item.UserProperties.Find("Utility")
End If
Else
Item.FileAs = Item.UserProperties.Find("Utility")
End If
End Select
End Sub

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



Cass said:
And just to be clear the fields are created and inside the form. They
are displayed in the "User-Defined Fields in Folder" folder and my
forms folder
Where they need to be present is in User-Defined Fields in This Item.
when I type into the Utility and CityState fields, the FileAs text box
doesn't update with the information
Code for the Item_Write event handler runs when you save the item. If you want the FileAs value to update when you type, that requires different events -- PropertyChange and CustomPropertyChange. Seehttp://www.outlookcode.com/article.aspx?ID=38
On Sep 21, 1:37 pm, "Sue Mosher [MVP-Outlook]"
Lots of problems here:
1) There is no FileAs event. You should use the Item_Write event handler.
2) There is no Utility standard property. Access custom properties through the UserProperties collection.
3) There is no CityState standard property. When in doubt, 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.
4) You don't need the parentheses in the Item.FileAs statement . Try:
Item.FileAs = Item.UserProperties("Utility") & vbcrlf & _
Item.City & " " & Item.State
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
I am creating a custom form with custom fields in outlook 2003.
The form that I am creating is a custom contact form. I want each
customer thats listed in this contact folder to be filed by the custom
fields that I created, Utility & CityState.
To do this i've tried adding the following formula to the form code:
Sub Item_FileAs
Item.FileAs = Item.Utility &vbcrlf " (" & Item.CityState & ")"
End Sub
To Display...
"Utilty
City State"
...In the gray area for the File As.
When I try to run the form, the form displayes this "9/21/2007 8:00:00
AM". Can someone help me figure out what's going on.- Hide quoted text -
- Show quoted text -
Ok so I tried:
Function Item_Write()
Item.FileAs = Item.UserProperties("Utility") & vbcrlf & _
Item.UserProperties("CityState")
End Function
It took away the date and displayed " ()" in the text box. However now
when I type into the Utility and CityState fields, the FileAs text box
doesn't update with the information- Hide quoted text -
- Show quoted text -
Thanks so much for your help so far...
You'll have to excuse me but that code throws me completely off...
Sub Item_CustomPropertyChange(ByVal Name)
Select Case Name
Case "MyProp1"
strMyProp1 = Item.UserProperties("MyProp1")
Select Case strMyProp1
Case "Text1"
' code to react to the MyProp1
' string property having a value of "Text1"
Case "Text2"
' code to react to the MyProp1
' string property having a value of "Text2"
Case Else
' code to handle other values of MyProp1
End Select
Case "MyProp2"
' code to handle a change in MyProp2 goes here
' continue with Case statements for other properties
' whose values you want to monitor
End Select
End Sub
I interpretted this by putting some other codes together that i'd
found:
Sub Item_CustomPropertyChange(FileAs)
Select Case Name
Case "Utility"
strUtility=Item.UserProperties("Utilities")
Select Case strUtility
Case "Text1"
If Item.UserProperties.Find("Utility") <> "" Then
If Item.UserProperties.Find("Utility") <> "" Then
Item.UserProperties.Find("Utility") & " (" &
Item.UserProperties.Find("Utility") & ")"
Else
Item.FileAs = Item.UserProperties.Find("Utility")
End If
Else
Item.FileAs = Item.UserProperties.Find("Utility")
End If
End Select
EndSub
Function Item_Write()
Item.FileAs = Item.UserProperties.Find("Utility") & vbcrlf & _
Item.UserProperties.Find("CityState")
End Function
And don't get me started on the PropertyChange code. I know this is
not right, not only because it didn't work but because I have no idea
how to code this. Could you help me to figure this out? Thanks!- Hide quoted text -

- Show quoted text -

What threw me off was the page that you sent me to for the most part
just told you where code needed to be so if you're not a programmer
figuring out how to translate that into what you need is hard. The
code I did really had no logic to it other than just trying to figure
out what to do.
 

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