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

Accessing Form1 control values from Form2



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 2nd 09, 11:57 PM posted to microsoft.public.outlook.program_vba
cmonroe21
external usenet poster
 
Posts: 5
Default Accessing Form1 control values from Form2

I have two forms, both with text boxes, labels and command buttons on them.
I need to be able to click the command button on Form2 and access the control
values in Form1 and place them into the controls on Form2. I just don't know
how to access a second form from the first one. Pretty basic, I know! If
you have any input, please let me know!

Ads
  #2  
Old January 3rd 09, 05:50 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Accessing Form1 control values from Form2

You cannot click a button in a form using code since the
MSForms.CommandButton control doesn't expose a Click or Execute or
equivalent method.

To get to another open item you iterate the Inspectors collection. Every
open item is in that collection. To identify the item you can check the
MessageClass, Subject or other property that you know will be unique.

Once you have the item's Inspector you use its ModifiedFormPages collection
to get the page (tab) and then use the page's Controls collection to access
specific controls:

' oInsp is the Inspector
Set oPage = oInsp.ModifiedFormPages.Item("myFormPageName")
Set oTextBox1 = oPage.Controls.Item("TextBox1Name")


--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"cmonroe21" u48566@uwe wrote in message news:8f9b010382c0e@uwe...
I have two forms, both with text boxes, labels and command buttons on them.
I need to be able to click the command button on Form2 and access the
control
values in Form1 and place them into the controls on Form2. I just don't
know
how to access a second form from the first one. Pretty basic, I know! If
you have any input, please let me know!


  #3  
Old January 6th 09, 06:00 PM posted to microsoft.public.outlook.program_vba
cmonroe21 via OfficeKB.com
external usenet poster
 
Posts: 53
Default Accessing Form1 control values from Form2

Thanks so much! I was sort of using this convention by:

Set objPage = Item.GetInspector.ModifiedFormPages("Message")
Set objControl = objPage.Controls("TextBox1")
MyValue - objControl.Value

But for some reason it wasn't working I've decided to scratch the Outlook
script editor and opt to use Vba in VB editor. Instead of messing with
swapping between the Message and P.2 tabs, and the compose and read messages,
I just created a form with the controls to inquire the data I need, then a
button that sends a newly created email item that contains the data.

Thanks so much for your help... the iterating between Inspectors is a new
concept for me. You would just create a loop to check the specific property
of each iteration? Veddy Inteddesting....

Ken Slovak - [MVP - Outlook] wrote:
You cannot click a button in a form using code since the
MSForms.CommandButton control doesn't expose a Click or Execute or
equivalent method.

To get to another open item you iterate the Inspectors collection. Every
open item is in that collection. To identify the item you can check the
MessageClass, Subject or other property that you know will be unique.

Once you have the item's Inspector you use its ModifiedFormPages collection
to get the page (tab) and then use the page's Controls collection to access
specific controls:

' oInsp is the Inspector
Set oPage = oInsp.ModifiedFormPages.Item("myFormPageName")
Set oTextBox1 = oPage.Controls.Item("TextBox1Name")

I have two forms, both with text boxes, labels and command buttons on them.
I need to be able to click the command button on Form2 and access the

[quoted text clipped - 3 lines]
how to access a second form from the first one. Pretty basic, I know! If
you have any input, please let me know!


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...g-vba/200901/1

 




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
Control the values in thread of the Read Page Sandi V Outlook - Using Forms 3 December 3rd 08 03:05 PM
multi select control not in my control toolbox GolfGal Outlook - Using Forms 4 August 13th 07 09:26 PM
Outlook View Control embedded in custom control [email protected] Outlook - General Queries 1 November 8th 06 11:41 AM
Outlook View Control embedded in custom control [email protected] Outlook - Using Forms 1 November 8th 06 11:41 AM
parameter values not valid when accessing calendar Suedra Outlook - Calandaring 3 March 5th 06 06:07 PM


All times are GMT +1. The time now is 03: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.