Can't pass date variable from form to procedure? 
Author Message
 Can't pass date variable from form to procedure?

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



Wed, 29 Oct 2003 15:42:49 GMT  
 Can't pass date variable from form to procedure?
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
------------------------------------------------

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



Wed, 29 Oct 2003 19:18:13 GMT  
 Can't pass date variable from form to procedure?
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


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



Wed, 29 Oct 2003 20:32:34 GMT  
 Can't pass date variable from form to procedure?
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

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



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



Thu, 30 Oct 2003 08:59:27 GMT  
 Can't pass date variable from form to procedure?
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


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


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



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



Thu, 30 Oct 2003 09:20:08 GMT  
 Can't pass date variable from form to procedure?
Thanks, Howard!  I will learn about the Get/Let method next!

-DD



Thu, 30 Oct 2003 11:06:15 GMT  
 Can't pass date variable from form to procedure?
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
------------------------------------------------

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


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



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



Thu, 30 Oct 2003 13:46:36 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Can't pass a NULL date parameter via ADO to SQL stored procedure

2. Pass variable from procedure to procedure

3. Passing variables between form's

4. passing date variable in select statment of recordset variable

5. 'Canned' data in VB program

6. Forms Collection: Using it to Open Forms by Passing the Form Name as a String Variable

7. Pass variable form module to a form

8. passing variable from procedure to module

9. Passing variables to ASM procedures in QB/QBasic

10. Pass global variable from form to form

11. Need help on passing variables to a Select case procedure

12. A Newbie having trouble passing variables from one sup-procedure to another

 

 
Powered by phpBB® Forum Software