+ Reply to Thread
Results 1 to 4 of 4

Passing arg to UserForm to use in Initialize

  1. #1
    Forum Contributor
    Join Date
    09-28-2007
    Location
    New York, NY
    MS-Off Ver
    2007
    Posts
    120

    Passing arg to UserForm to use in Initialize

    Hi all,

    I have a UserForm that already has some Initialize code in it. In this Init code, I want to use a Date that is pulled from a regular Module.

    So in my regular Module, I have a variable, dInputDate. I want to pass this to the Userform so that the Init code can use it.

    I tried putting this in my UF code:

    Please Login or Register  to view this content.
    then, I used dInputDateUF in my Init code...
    then, in my regular module, I have:

    Please Login or Register  to view this content.
    hoping that it would first call the Let property, but it doesn't...it calls the Init first. So, my data is not passed on via the Let before the Init.

    What is the proper way to do this? I know I can do public vars and stuff, but I want to know the correct way.


    Thanks,
    Joe

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: Passing arg to UserForm to use in Initialize

    Do you have to use the Initialize event or could you use the Activate event? If you need the former, then I think you would have to have the form call a public function to retrieve the required value, or use a public variable (or range, or name etc).
    Alternatively, add a public sub to the form that does your initializing code, and call that directly from the first sub, passing the date as an argument
    Last edited by romperstomper; 10-08-2009 at 12:39 PM.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Contributor
    Join Date
    09-28-2007
    Location
    New York, NY
    MS-Off Ver
    2007
    Posts
    120

    Re: Passing arg to UserForm to use in Initialize

    Yea, I guess I can just use the Activate event. Actually, it might be more appropriate for what I'm doing anyway since I might want to "re-initialize" when showing the UF a second time.


    Thanks,
    Joe

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,485

    Re: Passing arg to UserForm to use in Initialize

    Create your own initialize routine.

    Please Login or Register  to view this content.
    Userform code
    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1