+ Reply to Thread
Results 1 to 5 of 5

Calling multiple instances of a single userform

  1. #1
    Registered User
    Join Date
    04-23-2014
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    41

    Question Calling multiple instances of a single userform

    Greetings All,

    As a VBA novice I have played around and have successfully managed to select a date from a PopUpCalendar (MonthView Control) on the form and have the date placed in a textbox (txtBirthDate) located to the left of a command button

    My question is this - I would like to reuse the same PopUpCalendar for other textboxes (there are two on this form) and have the result returned to the left of each respective textbox.

    As you can see by the current form in the attached file, selecting the second calendar only serves to update the first textbox. I am not sure how to have the PopUpCalendar differentiate between textboxes. I would rather not create a new useform with a MonthView control to the side of each textbox as I believe this would be inefficient.

    Any assistance is appreciated and thank you for your time.
    Attached Files Attached Files

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

    Re: Calling multiple instances of a single userform

    First remove the code from the calendar userform that sets the text of a specific control on userform1.
    Replace that with a function that returns the date and one to determine whether the user cancelled the form or not.

    frmPopupCalendar code
    Please Login or Register  to view this content.
    Userform1 code
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    04-23-2014
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Calling multiple instances of a single userform

    Thank you Andy for the prompt response. Much appreciated. If I understand correctly, as many instances of object frmPopUpCalendar are created with the New command as required and the GetDate function property of that object returns a string value to the textbox?

    Thanks

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

    Re: Calling multiple instances of a single userform

    Only a single instance as it is created and destroyed within the routine.

    And yes the userform returns the date value via a function

  5. #5
    Registered User
    Join Date
    04-23-2014
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Calling multiple instances of a single userform

    Thank you Andy for the clarification and solution.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Copying single instances of multiple names
    By andrewc in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-01-2013, 04:56 AM
  2. Multiple Instances to Single Instance
    By jcholla in forum Excel General
    Replies: 2
    Last Post: 11-16-2011, 04:22 PM
  3. Multiple instances of the same userform.
    By mikerickson in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-10-2007, 09:56 PM
  4. Find Multiple instances of Single Criterion in Row & Return To a Single Col
    By Sam via OfficeKB.com in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 05-09-2006, 10:10 PM

Tags for this Thread

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