+ Reply to Thread
Results 1 to 4 of 4

Calendar control question

Hybrid View

  1. #1
    Forum Contributor Gabor's Avatar
    Join Date
    02-15-2004
    Location
    Székesfehérvár, Hungary
    MS-Off Ver
    xl2016
    Posts
    226

    Calendar control question

    Hi,

    I have a UserForm with about 80 controls filling a datasheet, works fine, now I would like to use the Calendar control to help the users to enter Dates. I have about 7 TextBoxes on the form to enter Dates and I thought a separate UserForm would be opened at DblClick event on those TextBoxes which are supposed to be used for Date entries into the database.
    So far so good, I have made up that second UForm and the event opens it up no problem.
    I have however the difficulty to get the selected Date into the respective TextBox and in to the database.
    It seems as though I can only solve this if I make up as many Uforms as many TextBoxes I want to enter dates.
    There must be a better way.
    Any help would be much appreciated.

    Gabor

  2. #2
    Forum Contributor
    Join Date
    01-24-2007
    Location
    Southampton, UK
    Posts
    137
    One initial idea may be to define a public variable.

    When the calendar form is opened (Initialize event) the variable is set to nothing, and when the calendar form is closed (Terminate event) it is set to whatever date the user selects.

    When the code returns to the original form to finish off the DblClick event, the contents of the global variable are put in the active text box.

    If you're not sure how to set this all up, you will need to post an example of your workbook so that we can examine your current set-up.

  3. #3
    Forum Contributor Gabor's Avatar
    Join Date
    02-15-2004
    Location
    Székesfehérvár, Hungary
    MS-Off Ver
    xl2016
    Posts
    226

    Global variable

    G'Day, thanks for replying,

    How do I define a global variable?
    Is it something to do with the Static keyword?
    I have tried to define a variable in ThisWorkbook, but for some reason it did not work.

    Gabor

  4. #4
    Forum Contributor Gabor's Avatar
    Join Date
    02-15-2004
    Location
    Székesfehérvár, Hungary
    MS-Off Ver
    xl2016
    Posts
    226

    Gotcha!!

    I declared a variable on a normal module like
    Public MyDate

    This then can be set by either of the userforms and can be used across.
    Thanks for the hint, I helped.

    Gabor

+ 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