Consulting

Results 1 to 15 of 15

Thread: A date picker userform for Mac.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,776

    A date picker userform for Mac.

    People have been inquiring about a Date Picker for Mac, so I came up with this userform.
    The syntax for using it is
    Dim uiDate As Double
    Dim strPrompt As String
    strPrompt = "Please enter the date of your choosing."
    uiDate = macDate.Chosen(strPrompt, Default:=DateSerial(1919, 5, 3), Title:="Pick a Date", DefaultButton:=vbDefaultButton1)
    '  all arguments are optional
    ' defaults prompt="Choose a date.", default=today's date, title="Choose Date", defaultButton=vbDefaultButton1
    If uiDate = False Then
        Rem MsgBox "canceled"
    Else
        MsgBox "You chose " & Format(uiDate, "d. mmm, yyyy.")
    End If
    The sub FillMacDateWithControls will take an empty userform, named macDate, and put the necessary controls in the proper place.
    Attached Files Attached Files

  2. #2
    Very cool example. I'm surprised not any discussion after you uploaded. I found this with a google search for Mac Date Picker after I wrote my own for use within a form. Yours is a TON more comprehensive, and there is so much to learn in your demo. Thanks very much for sharing it!

    Kevin

  3. #3
    Yes this is the most elegant out there... Forgive my ignorance, but could you tell me if this would work from another user form? And insert eh chosen date into a text box?Even if you can't answer, thank you.David

  4. #4
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,776
    It should work from another userform.

    I'm at work and can't test, but I would create a userform, with a command button, a text box and this code and see what happens.
    Private Sub CommandButton1_Click()
        Dim uiDate As String
        
        uiDate = macDate.Chosen
        
        If uiDate = False Then
            MsgBox "canceled"
        Else
            TextBox1.Text = Format(uiDate, "mm/dd/yyyy")
    End Sub
    The userform that is the date picker must be named macDate.

  5. #5

    thank you

    Quote Originally Posted by mikerickson View Post
    It should work from another userform.

    I'm at work and can't test, but I would create a userform, with a command button, a text box and this code and see what happens.
    Private Sub CommandButton1_Click()
        Dim uiDate As String
        
        uiDate = macDate.Chosen
        
        If uiDate = False Then
            MsgBox "canceled"
        Else
            TextBox1.Text = Format(uiDate, "mm/dd/yyyy")
    End Sub
    The userform that is the date picker must be named macDate.
    __________


    mikerickson you are the bomb! totally saved my life it would have taken me months if not years to determine how to program that. thank you for sharing your knowledge and please continue to do so!

  6. #6
    VBAX Newbie
    Joined
    Apr 2015
    Posts
    2
    Location
    Very cool. thanks Mike.

  7. #7
    Thank you!

    Quote Originally Posted by mikerickson View Post
    It should work from another userform.

    I'm at work and can't test, but I would create a userform, with a command button, a text box and this code and see what happens.
    Private Sub CommandButton1_Click()
        Dim uiDate As String
        
        uiDate = macDate.Chosen
        
        If uiDate = False Then
            MsgBox "canceled"
        Else
            TextBox1.Text = Format(uiDate, "mm/dd/yyyy")
    End Sub
    The userform that is the date picker must be named macDate.

  8. #8
    Wow that was a quick reply! I was going to say don't worry because Ive solved it - using your form of course...Seems to work perfectly using an adapted version of your implementation codeTruly grateful for your generosity...David

  9. #9
    VBAX Newbie
    Joined
    Apr 2015
    Posts
    2
    Location
    Sorry to resurrect an old discussion, but I can't figure out why the user form provided my Mike resizes based on the location of the Cancel button. I downloaded the sample file, and am just looking to move the Cancel and OK buttons below the calendar vs. to the right of the calendar. When I do this, the with of the entire form automatically resizes to where ever the cancel button is located. Example: If i move the cancel button to below the calendar to the left, the width of the entire form shrinks (see attached image). Conversely, if I move the Cancel button way out to the right the form expands. Note: the OK button seems to have no impact on the form size.

    I can't seem to figure out what's causing this. Any help would be appreciated.

    2015-04-11_11-34-20.jpg

  10. #10
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,776
    Quote Originally Posted by dmc311 View Post
    ... looking to move the Cancel and OK buttons below the calendar vs. to the right of the calendar. ....
    Change this section in the Useform_Activate code.
    With Me
            .Height = Application.Max(.butCancel.Top + .butCancel.Height + 10, frameUserEntryControls.Top + .frameUserEntryControls.Height + 35) + (.Height - .InsideHeight)
            .Width = Application.Max(2 * .frameUserEntryControls.Left + .frameUserEntryControls.Width, .butCancel.Left + .butCancel.Width + 10) + (.Width - .InsideWidth)
            .Tag = "shown"
        End With

  11. #11
    VBAX Newbie
    Joined
    Jul 2015
    Posts
    1
    Location

    thanks

    Quote Originally Posted by mikerickson View Post
    People have been inquiring about a Date Picker for Mac, so I came up with this userform.
    The syntax for using it is
    Dim uiDate As Double
    Dim strPrompt As String
    strPrompt = "Please enter the date of your choosing."
    uiDate = macDate.Chosen(strPrompt, Default:=DateSerial(1919, 5, 3), Title:="Pick a Date", DefaultButton:=vbDefaultButton1)
    '  all arguments are optional
    ' defaults prompt="Choose a date.", default=today's date, title="Choose Date", defaultButton=vbDefaultButton1
    If uiDate = False Then
        Rem MsgBox "canceled"
    Else
        MsgBox "You chose " & Format(uiDate, "d. mmm, yyyy.")
    End If
    The sub FillMacDateWithControls will take an empty userform, named macDate, and put the necessary controls in the proper place.

  12. #12
    Got one also on my site, can't post a link because of this error.

    >Post denied. New posts are limited by number of URLs it may contain and checked if it doesn't contain forbidden words.

    Can anybody tell me how to post a link

  13. #13
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,776
    Here's the link to Ron's date picker
    http://www.rondebruin.nl/mac/addins/datepicker.htm

  14. #14
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,645
    your post count should be at least 5 in order to post a link Ron.

    you are an old member. hope to see you here more often.

    btw, thanks for your excellent site.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  15. #15
    VBAX Newbie
    Joined
    Mar 2024
    Posts
    1
    Location
    Quote Originally Posted by mikerickson View Post
    People have been inquiring about a Date Picker for Mac, so I came up with this userform.
    Wow, great work. Thank you so much!

Posting Permissions

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