A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Copy 1 Text Field into another on Form, DateAdd and macros



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 17th 06, 09:24 AM posted to microsoft.public.outlook.program_vba
Michael Anderson
external usenet poster
 
Posts: 19
Default Copy 1 Text Field into another on Form, DateAdd and macros

1. How do I copy 1 text Field's value into another text Field from a cmd
button? I am trying to customise the Outlook Contact Form. I notice that
there is no code underneath it and so I can't debug it with MS Script Editor.
2. Why doesn't the code below work? I've used DateAdd to add 12 months on to
a date...
-- below is code -- (mxz...is a user-defined prefix)

Sub Item_CustomPropertyChange(ByVal Name)
If Name = "mxzMembershipStartDat" Then
Dim dteNextDate As Date
Dim dteDate As Date

dteDate = dtemxzMembershipStartDat
dteNextDate = DateAdd("m", 12, dteDate)
dtemxzMembershipRenewalMonth = dteNextDate
End If
End Sub


3. How can i get 2 macros to load automatically with a form?

--
Thank You in Advance,

Michael Anderson
Ads
  #2  
Old January 17th 06, 07:01 PM posted to microsoft.public.outlook.program_vba
Tangent
external usenet poster
 
Posts: 2
Default Copy 1 Text Field into another on Form, DateAdd and macros

Well, it's really the same soultion: You have to pull the objects from the
Item.UserProperties() collection to do things with them. This is also why
your function does not work. Something like this works:

Sub Item_CustomPropertyChange(ByVal Name)
If Name = "dateField1" Then
dteDate = Item.UserProperties("dateField1").Value
dteNextDate = DateAdd("m", 12, dteDate)
Item.UserProperties("dateField2").Value = dteNextDate
End If
End Sub

Update other textboxes the same way. If you are entering data in to builtin
fields, just make sure you access them through the right collection.

Regarding loading two macros with a form, I'm not sure what you're asking.
Do you want to embed the macros in the form? Or do you want to launch macros
that exist in your VBAProject.OTM (these are the macros that you see in the
Tools Macros... list, they are specific to each PC's VBAProject.OTM file
unless you have a deployment soultion in place).

Thanks,
Tangent

"Michael Anderson" wrote:

1. How do I copy 1 text Field's value into another text Field from a cmd
button? I am trying to customise the Outlook Contact Form. I notice that
there is no code underneath it and so I can't debug it with MS Script Editor.
2. Why doesn't the code below work? I've used DateAdd to add 12 months on to
a date...
-- below is code -- (mxz...is a user-defined prefix)

Sub Item_CustomPropertyChange(ByVal Name)
If Name = "mxzMembershipStartDat" Then
Dim dteNextDate As Date
Dim dteDate As Date

dteDate = dtemxzMembershipStartDat
dteNextDate = DateAdd("m", 12, dteDate)
dtemxzMembershipRenewalMonth = dteNextDate
End If
End Sub


3. How can i get 2 macros to load automatically with a form?

--
Thank You in Advance,

Michael Anderson

  #3  
Old January 17th 06, 09:02 PM posted to microsoft.public.outlook.program_vba
Michael Anderson
external usenet poster
 
Posts: 19
Default Copy 1 Text Field into another on Form, DateAdd and macros

THanks for your help.

RE 3rd question - I want to embed these macros on a form. When the form
loads, these macros would be embedded in it. 1 of these cmd_click()macros
performs the actions of the 1st question. The other cmd_click()macro updates
another date field (see 2nd question). I was asking this in case the direct
programming on the forms didn't work. (Like 2nd Question - ie Sub
Item_CustomPropertyChange(...))
--
Thank You in Advance,

Michael Anderson


"Tangent" wrote:

Well, it's really the same soultion: You have to pull the objects from the
Item.UserProperties() collection to do things with them. This is also why
your function does not work. Something like this works:

Sub Item_CustomPropertyChange(ByVal Name)
If Name = "dateField1" Then
dteDate = Item.UserProperties("dateField1").Value
dteNextDate = DateAdd("m", 12, dteDate)
Item.UserProperties("dateField2").Value = dteNextDate
End If
End Sub

Update other textboxes the same way. If you are entering data in to builtin
fields, just make sure you access them through the right collection.

Regarding loading two macros with a form, I'm not sure what you're asking.
Do you want to embed the macros in the form? Or do you want to launch macros
that exist in your VBAProject.OTM (these are the macros that you see in the
Tools Macros... list, they are specific to each PC's VBAProject.OTM file
unless you have a deployment soultion in place).

Thanks,
Tangent

"Michael Anderson" wrote:

1. How do I copy 1 text Field's value into another text Field from a cmd
button? I am trying to customise the Outlook Contact Form. I notice that
there is no code underneath it and so I can't debug it with MS Script Editor.
2. Why doesn't the code below work? I've used DateAdd to add 12 months on to
a date...
-- below is code -- (mxz...is a user-defined prefix)

Sub Item_CustomPropertyChange(ByVal Name)
If Name = "mxzMembershipStartDat" Then
Dim dteNextDate As Date
Dim dteDate As Date

dteDate = dtemxzMembershipStartDat
dteNextDate = DateAdd("m", 12, dteDate)
dtemxzMembershipRenewalMonth = dteNextDate
End If
End Sub


3. How can i get 2 macros to load automatically with a form?

--
Thank You in Advance,

Michael Anderson

  #4  
Old January 17th 06, 10:07 PM posted to microsoft.public.outlook.program_vba
msnews.microsoft.com
external usenet poster
 
Posts: 2
Default Copy 1 Text Field into another on Form, DateAdd and macros

Ah. Well, in the event that you still wanted to handle clicks, you would
embed the macros the same way you created the custompropertychange event
handler. only it would be a click handler. Then you'd just check what they
clicked on, and then execute the proper code - or do nothing.

I personally like to leave buttons out of it if possible. Your use of the
CustomPropertyChange event is preferrable.

Thanks,
Tangent

"Michael Anderson" wrote in
message ...
THanks for your help.

RE 3rd question - I want to embed these macros on a form. When the form
loads, these macros would be embedded in it. 1 of these cmd_click()macros
performs the actions of the 1st question. The other cmd_click()macro
updates
another date field (see 2nd question). I was asking this in case the
direct
programming on the forms didn't work. (Like 2nd Question - ie Sub
Item_CustomPropertyChange(...))
--
Thank You in Advance,

Michael Anderson


"Tangent" wrote:

Well, it's really the same soultion: You have to pull the objects from
the
Item.UserProperties() collection to do things with them. This is also
why
your function does not work. Something like this works:

Sub Item_CustomPropertyChange(ByVal Name)
If Name = "dateField1" Then
dteDate = Item.UserProperties("dateField1").Value
dteNextDate = DateAdd("m", 12, dteDate)
Item.UserProperties("dateField2").Value = dteNextDate
End If
End Sub

Update other textboxes the same way. If you are entering data in to
builtin
fields, just make sure you access them through the right collection.

Regarding loading two macros with a form, I'm not sure what you're
asking.
Do you want to embed the macros in the form? Or do you want to launch
macros
that exist in your VBAProject.OTM (these are the macros that you see in
the
Tools Macros... list, they are specific to each PC's VBAProject.OTM
file
unless you have a deployment soultion in place).

Thanks,
Tangent

"Michael Anderson" wrote:

1. How do I copy 1 text Field's value into another text Field from a
cmd
button? I am trying to customise the Outlook Contact Form. I notice
that
there is no code underneath it and so I can't debug it with MS Script
Editor.
2. Why doesn't the code below work? I've used DateAdd to add 12 months
on to
a date...
-- below is code -- (mxz...is a user-defined prefix)

Sub Item_CustomPropertyChange(ByVal Name)
If Name = "mxzMembershipStartDat" Then
Dim dteNextDate As Date
Dim dteDate As Date

dteDate = dtemxzMembershipStartDat
dteNextDate = DateAdd("m", 12, dteDate)
dtemxzMembershipRenewalMonth = dteNextDate
End If
End Sub


3. How can i get 2 macros to load automatically with a form?

--
Thank You in Advance,

Michael Anderson



  #5  
Old January 17th 06, 10:20 PM posted to microsoft.public.outlook.program_vba
Michael Anderson
external usenet poster
 
Posts: 19
Default Copy 1 Text Field into another on Form, DateAdd and macros

Here is some more RE questions 1 and 2.

Below is the only code on a customised Outlook Form. Nothing happens. Can
anyone please tell me why?

Sub Item_CustomPropertyChange(ByVal Name)

Dim dteNextDate as Date
Dim dteDate as Date
Dim objApp as Application
Dim objNS as NameSpace

Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")

If Name = "mxzMembershipStartDate" Then
dteDate = Item.UserProperties("mxzMembershipStartDate").Valu e
dteNextDate = DateAdd("m", 12, dteDate)
Item.UserProperties("mxzMembershipRenewalMonth").V alue = dteNextDate
End If

Set objApp = Nothing
Set objNS = Nothing

End Sub

Sub cmdmxzAddressButton_Click()

Dim objApp as Application
Dim objNS as NameSpace

Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")

Item.UserProperties("mxzBusinessSuburb").Value =
Item.UserProperties("mxzOtherSuburb").Value

Set objApp = Nothing
Set objNS = Nothing

End Sub


I also get the Error Message 3 before the Form loads saying "Expected End of
Statement Line 3".

--
Thank You in Advance,

Michael Anderson


"Michael Anderson" wrote:

1. How do I copy 1 text Field's value into another text Field from a cmd
button? I am trying to customise the Outlook Contact Form. I notice that
there is no code underneath it and so I can't debug it with MS Script Editor.
2. Why doesn't the code below work? I've used DateAdd to add 12 months on to
a date...
-- below is code -- (mxz...is a user-defined prefix)

Sub Item_CustomPropertyChange(ByVal Name)
If Name = "mxzMembershipStartDat" Then
Dim dteNextDate As Date
Dim dteDate As Date

dteDate = dtemxzMembershipStartDat
dteNextDate = DateAdd("m", 12, dteDate)
dtemxzMembershipRenewalMonth = dteNextDate
End If
End Sub


3. How can i get 2 macros to load automatically with a form?

--
Thank You in Advance,

Michael Anderson

  #6  
Old January 17th 06, 10:55 PM posted to microsoft.public.outlook.program_vba
msnews.microsoft.com
external usenet poster
 
Posts: 2
Default Copy 1 Text Field into another on Form, DateAdd and macros

Michael:

Comment out all of the lines having to do with objApp and objNS, and comment
out all of the Dim statements. Then run your form again.

The reason it doesn't do anything is because Expected EOL error dumps the
entire script. Thus, no scripts run on that page. The EOL error is coming
from your Dim objApp as Application.

In this particular case, don't worry about Dims and I'm not really sure why
you're grabbing objApp or objNS, just to connect/logon? I don't think you
need to worry about it unless you plan to do something with our friend
MAPI... like send mail.

Thanks,
Tangent

"Michael Anderson" wrote in
message news
Here is some more RE questions 1 and 2.

Below is the only code on a customised Outlook Form. Nothing happens. Can
anyone please tell me why?

Sub Item_CustomPropertyChange(ByVal Name)

Dim dteNextDate as Date
Dim dteDate as Date
Dim objApp as Application
Dim objNS as NameSpace

Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")

If Name = "mxzMembershipStartDate" Then
dteDate = Item.UserProperties("mxzMembershipStartDate").Valu e
dteNextDate = DateAdd("m", 12, dteDate)
Item.UserProperties("mxzMembershipRenewalMonth").V alue = dteNextDate
End If

Set objApp = Nothing
Set objNS = Nothing

End Sub

Sub cmdmxzAddressButton_Click()

Dim objApp as Application
Dim objNS as NameSpace

Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")

Item.UserProperties("mxzBusinessSuburb").Value =
Item.UserProperties("mxzOtherSuburb").Value

Set objApp = Nothing
Set objNS = Nothing

End Sub


I also get the Error Message 3 before the Form loads saying "Expected End
of
Statement Line 3".

--
Thank You in Advance,

Michael Anderson


"Michael Anderson" wrote:

1. How do I copy 1 text Field's value into another text Field from a cmd
button? I am trying to customise the Outlook Contact Form. I notice that
there is no code underneath it and so I can't debug it with MS Script
Editor.
2. Why doesn't the code below work? I've used DateAdd to add 12 months on
to
a date...
-- below is code -- (mxz...is a user-defined prefix)

Sub Item_CustomPropertyChange(ByVal Name)
If Name = "mxzMembershipStartDat" Then
Dim dteNextDate As Date
Dim dteDate As Date

dteDate = dtemxzMembershipStartDat
dteNextDate = DateAdd("m", 12, dteDate)
dtemxzMembershipRenewalMonth = dteNextDate
End If
End Sub


3. How can i get 2 macros to load automatically with a form?

--
Thank You in Advance,

Michael Anderson



  #7  
Old January 17th 06, 11:22 PM posted to microsoft.public.outlook.program_vba
Michael Anderson
external usenet poster
 
Posts: 19
Default Copy 1 Text Field into another on Form, DateAdd and macros

Thank You for your help.

I've done what you have said, but nothing happens.
--
Thank You in Advance,

Michael Anderson


"msnews.microsoft.com" wrote:

Michael:

Comment out all of the lines having to do with objApp and objNS, and comment
out all of the Dim statements. Then run your form again.

The reason it doesn't do anything is because Expected EOL error dumps the
entire script. Thus, no scripts run on that page. The EOL error is coming
from your Dim objApp as Application.

In this particular case, don't worry about Dims and I'm not really sure why
you're grabbing objApp or objNS, just to connect/logon? I don't think you
need to worry about it unless you plan to do something with our friend
MAPI... like send mail.

Thanks,
Tangent

"Michael Anderson" wrote in
message news
Here is some more RE questions 1 and 2.

Below is the only code on a customised Outlook Form. Nothing happens. Can
anyone please tell me why?

Sub Item_CustomPropertyChange(ByVal Name)

Dim dteNextDate as Date
Dim dteDate as Date
Dim objApp as Application
Dim objNS as NameSpace

Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")

If Name = "mxzMembershipStartDate" Then
dteDate = Item.UserProperties("mxzMembershipStartDate").Valu e
dteNextDate = DateAdd("m", 12, dteDate)
Item.UserProperties("mxzMembershipRenewalMonth").V alue = dteNextDate
End If

Set objApp = Nothing
Set objNS = Nothing

End Sub

Sub cmdmxzAddressButton_Click()

Dim objApp as Application
Dim objNS as NameSpace

Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")

Item.UserProperties("mxzBusinessSuburb").Value =
Item.UserProperties("mxzOtherSuburb").Value

Set objApp = Nothing
Set objNS = Nothing

End Sub


I also get the Error Message 3 before the Form loads saying "Expected End
of
Statement Line 3".

--
Thank You in Advance,

Michael Anderson


"Michael Anderson" wrote:

1. How do I copy 1 text Field's value into another text Field from a cmd
button? I am trying to customise the Outlook Contact Form. I notice that
there is no code underneath it and so I can't debug it with MS Script
Editor.
2. Why doesn't the code below work? I've used DateAdd to add 12 months on
to
a date...
-- below is code -- (mxz...is a user-defined prefix)

Sub Item_CustomPropertyChange(ByVal Name)
If Name = "mxzMembershipStartDat" Then
Dim dteNextDate As Date
Dim dteDate As Date

dteDate = dtemxzMembershipStartDat
dteNextDate = DateAdd("m", 12, dteDate)
dtemxzMembershipRenewalMonth = dteNextDate
End If
End Sub


3. How can i get 2 macros to load automatically with a form?

--
Thank You in Advance,

Michael Anderson




  #8  
Old January 18th 06, 01:52 AM posted to microsoft.public.outlook.program_vba
Michael Anderson
external usenet poster
 
Posts: 19
Default Copy 1 Text Field into another on Form, DateAdd and macros

Sorry, anyone got any suggestions as to why I get the Error Message # 3
before the Form loads saying "Expected End of Statement Line 3".

--
Thank You in Advance,

Michael Anderson


"Michael Anderson" wrote:

Thank You for your help.

I've done what you have said, but nothing happens.
--
Thank You in Advance,

Michael Anderson


"msnews.microsoft.com" wrote:

Michael:

Comment out all of the lines having to do with objApp and objNS, and comment
out all of the Dim statements. Then run your form again.

The reason it doesn't do anything is because Expected EOL error dumps the
entire script. Thus, no scripts run on that page. The EOL error is coming
from your Dim objApp as Application.

In this particular case, don't worry about Dims and I'm not really sure why
you're grabbing objApp or objNS, just to connect/logon? I don't think you
need to worry about it unless you plan to do something with our friend
MAPI... like send mail.

Thanks,
Tangent

"Michael Anderson" wrote in
message news
Here is some more RE questions 1 and 2.

Below is the only code on a customised Outlook Form. Nothing happens. Can
anyone please tell me why?

Sub Item_CustomPropertyChange(ByVal Name)

Dim dteNextDate as Date
Dim dteDate as Date
Dim objApp as Application
Dim objNS as NameSpace

Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")

If Name = "mxzMembershipStartDate" Then
dteDate = Item.UserProperties("mxzMembershipStartDate").Valu e
dteNextDate = DateAdd("m", 12, dteDate)
Item.UserProperties("mxzMembershipRenewalMonth").V alue = dteNextDate
End If

Set objApp = Nothing
Set objNS = Nothing

End Sub

Sub cmdmxzAddressButton_Click()

Dim objApp as Application
Dim objNS as NameSpace

Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")

Item.UserProperties("mxzBusinessSuburb").Value =
Item.UserProperties("mxzOtherSuburb").Value

Set objApp = Nothing
Set objNS = Nothing

End Sub


I also get the Error Message 3 before the Form loads saying "Expected End
of
Statement Line 3".

--
Thank You in Advance,

Michael Anderson


"Michael Anderson" wrote:

1. How do I copy 1 text Field's value into another text Field from a cmd
button? I am trying to customise the Outlook Contact Form. I notice that
there is no code underneath it and so I can't debug it with MS Script
Editor.
2. Why doesn't the code below work? I've used DateAdd to add 12 months on
to
a date...
-- below is code -- (mxz...is a user-defined prefix)

Sub Item_CustomPropertyChange(ByVal Name)
If Name = "mxzMembershipStartDat" Then
Dim dteNextDate As Date
Dim dteDate As Date

dteDate = dtemxzMembershipStartDat
dteNextDate = DateAdd("m", 12, dteDate)
dtemxzMembershipRenewalMonth = dteNextDate
End If
End Sub


3. How can i get 2 macros to load automatically with a form?

--
Thank You in Advance,

Michael Anderson




  #9  
Old January 18th 06, 05:10 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Copy 1 Text Field into another on Form, DateAdd and macros

Is that with form code? Form code is VBScript, where everything is a Variant
and As clauses are not allowed.

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


"Michael Anderson" wrote in
message ...
Sorry, anyone got any suggestions as to why I get the Error Message # 3
before the Form loads saying "Expected End of Statement Line 3".

--
Thank You in Advance,

Michael Anderson


  #10  
Old January 18th 06, 11:37 PM posted to microsoft.public.outlook.program_vba
Michael Anderson
external usenet poster
 
Posts: 19
Default Copy 1 Text Field into another on Form, DateAdd and macros

Thank you for your help.
--
Thank You in Advance,

Michael Anderson


"Michael Anderson" wrote:

1. How do I copy 1 text Field's value into another text Field from a cmd
button? I am trying to customise the Outlook Contact Form. I notice that
there is no code underneath it and so I can't debug it with MS Script Editor.
2. Why doesn't the code below work? I've used DateAdd to add 12 months on to
a date...
-- below is code -- (mxz...is a user-defined prefix)

Sub Item_CustomPropertyChange(ByVal Name)
If Name = "mxzMembershipStartDat" Then
Dim dteNextDate As Date
Dim dteDate As Date

dteDate = dtemxzMembershipStartDat
dteNextDate = DateAdd("m", 12, dteDate)
dtemxzMembershipRenewalMonth = dteNextDate
End If
End Sub


3. How can i get 2 macros to load automatically with a form?

--
Thank You in Advance,

Michael Anderson

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy and paste Contacts as text not vCards J. Pierre Moatti Outlook - Using Contacts 5 January 28th 08 12:23 AM
Change messageBox text when Outlook form field not validated JennD Outlook - Using Forms 0 February 23rd 06 09:17 PM
How do I copy data from one field to another? reiner Outlook - Using Contacts 3 February 19th 06 08:56 PM
Copy and paste name and address from OL to text R. Barre Outlook - Using Contacts 1 February 9th 06 06:21 AM
Populate Company field from Contact field in custom task form Sue Mosher [MVP-Outlook] Outlook - Using Forms 0 January 20th 06 08:37 PM


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


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.