Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can't pass date variable from form to procedure?

6 views
Skip to first unread message

Don Dillinger

unread,
May 12, 2001, 3:42:49 AM5/12/01
to
Hi,

I'm trying to get a form to pass a date to the parent Procedure VBA macro in
Outlook, but the procedure can't seem to pick up the variable from the form.

I'm using a public procedure, with the variable declared "dateStart as Date"
(no quotes in the code!), then loading the form and getting the user entry
from the click event as follows:
Private Sub cmdOK_Click()

frmMsgBoxGetDate.Hide
Unload frmMsgBoxGetDate
dateStart = txtdateStart.Value

...a msgBox will display the correct entry in the form sub, but not in the
procedure sub.

Is there something about the Date variable type that is confusing things?
I've tried various combinations of public and private variables, and even
calling a sub within the procedure, but can't seem to bring up this
variable; it just comes up as null or "12:00:00 AM" depending on the
variable type declared in the procedure....

Any clues as to what I'm doing wrong here?

Maybe it's something about the relationship between the form and the module
that I'm ignorant of??

Many thanks,

--
Don Dillinger
Home page: www.geocities.com/Snohomish_Observatory

Howard Kaikow

unread,
May 12, 2001, 7:18:13 AM5/12/01
to
You may "pass" values from a userform to a standard module by:

1. Passing as a parameter calling a Public Sub/Function in a standard
module.
2. Using a Public variable in a Standard module.
3. Property Get/Let
6. Using an initialization file or registry setting.

--
Please post your response to the newsgroup.

http://www.standards.com/ipusers/standards; Word macros, including
converting from WordBasic to VBA; Technical writing and reviewing; Standards
------------------------------------------------
"Don Dillinger" <dill...@foxinternet.com> wrote in message
news:3afce...@news.foxinternet.com...

Sue Mosher

unread,
May 12, 2001, 8:32:34 AM5/12/01
to
Is dateStart declared as a module- or global-level variable? Did you try
setting its value *before* you unload the form? You might also consider
revising the public procedure so that you can pass the date directly to it:

Call MyProc(txtdateStart.Value)

--

Sue Mosher, Outlook MVP
Author of
Teach Yourself Microsoft Outlook 2000 Programming in 24 Hours
Microsoft Outlook 2000 E-mail and Fax Guide
Outlook and Exchange solutions at http://www.slipstick.com

"Don Dillinger" <dill...@foxinternet.com> wrote in message
news:3afce...@news.foxinternet.com...

Don Dillinger

unread,
May 12, 2001, 8:59:27 PM5/12/01
to
Thanks to you both for the quick reply!

I think I've isolated the problem:
Getting the variable to go "public" seemed to require that I put the
procedure in a module separate from the "thisOutlookSession," which for
some reason is where the macro procedure got placed to begin with.

This is probably obvious to the initiated; I don't really understand the
relationships between these items in the object browser. It would seem to
me that a procedure written in "thisOutlookSession" would make variables
available to other code in the same project, if labeled as public...

Sue, does your book cover "restrict method" in any detail?

thanks,

Don


ed setting dateStart as Public (in the
"Sue Mosher" <sue...@slipstick.com> wrote in message
news:udex58t2AHA.1984@tkmsftngp05...

Sue Mosher

unread,
May 12, 2001, 9:20:08 PM5/12/01
to
Yes, on pp. 261-3. You'll also get a lot of examples if you search this
group at groups.google.com.

--

Sue Mosher, Outlook MVP
Author of
Teach Yourself Microsoft Outlook 2000 Programming in 24 Hours
Microsoft Outlook 2000 E-mail and Fax Guide
Outlook and Exchange solutions at http://www.slipstick.com

"Don Dillinger" <dill...@foxinternet.com> wrote in message

news:3afdd...@news.foxinternet.com...

Don Dillinger

unread,
May 12, 2001, 11:06:15 PM5/12/01
to
Thanks, Howard! I will learn about the Get/Let method next!

-DD


Howard Kaikow

unread,
May 13, 2001, 1:46:36 AM5/13/01
to
That is documented behavior.

Public "stuff" has to be in a standard module.

--
Please post your response to the newsgroup.

http://www.standards.com/ipusers/standards; Word macros, including
converting from WordBasic to VBA; Technical writing and reviewing; Standards
------------------------------------------------

"Don Dillinger" <dill...@foxinternet.com> wrote in message

news:3afdd...@news.foxinternet.com...

0 new messages