Results 1 to 14 of 14
  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Date & Time Picker (A2000 SR1)

    Is it possible for the Date & Time Picker to automatically open on enter or got focus ?

    Thanks
    Dave

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Date & Time Picker (A2000 SR1)

    Do you mean instead of on Click? I wouldn't really recommend that behavior, but what are you trying to accomplish?
    Charlotte

  3. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date & Time Picker (A2000 SR1)

    On entering the control, if the user press's F4, much like a combo, the D&T Picker opens for the user to select a date.

    f the item was a combo, I could use something Like:On Enter - Me.Dropdown instead of the user pressing the VBKey.

    Because this is an ActiveX Component, the same syntax doesn't work.

    Basically when the control has focus or is enterred, Dropdown for the user to select a date.

    Thanks

    Dave

  4. #4
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date & Time Picker (A2000 SR1)

    Hi Dave

    I use the following on date and time picker to stay in line with billie bobs standards (and some of my own) as with combo and list boxes.

    When your in the date field the following shortcuts pops the calendar:

    F4
    Alt + Down Arrow
    Ctrl + D (for Date, T for time)

    Private Sub dtmLicenseDate_KeyDown(KeyCode As Integer, Shift As Integer)

    If KeyCode = (vbKeyDown And Shift = acAltMask) Or _
    KeyCode = vbKeyF4 Or KeyCode = vbKeyD Then ' vbKeyT for time
    Call Display_Calendar_for_License_Date_Click
    End If

    End Sub

    HTH

    John

  5. #5
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date & Time Picker (A2000 SR1)

    This is what I had more in mind, as I use with my combo's

    Private Sub Estimator_GotFocus()
    If IsNull([Estimator]) Then
    [Estimator].Dropdown
    End If
    End Sub

    With this, the combo automatically drops down if no entry is made in the Estimator Combo.
    I would like the Date & Time Picker do the same so no user intervention is required.

    Is this possible

    Dave

  6. #6
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Date & Time Picker (A2000 SR1)

    Dave,
    As far as I'm aware there is no equivalent dropdown method of a DTPicker. My best guess would be that you need to use SendKeys (shudder) or an API equivalent.
    HTH.
    Regards,
    Rory

    Microsoft MVP - Excel

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Date & Time Picker (A2000 SR1)

    The DateTime Picker has a Dropdown event but not a dropdown method. I don't know of any way to do this except possibly sendkeys.
    Charlotte

  8. #8
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Date & Time Picker (A2000 SR1)

    Dave,
    I've been doing some thinking about this and have come up with the following (tested on A2K on WinXPPro) using some sample code from AllAPI:
    You need a module with the following code:
    <pre>Option Compare Database

    Private Declare Function SendInput Lib "user32.dll" (ByVal nInputs As Long, _
    pInputs As GENERALINPUT, ByVal cbSize As Long) As Long
    Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
    (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
    Public Const VK_F4 = 115
    Const KEYEVENTF_KEYUP = &H2
    Const INPUT_KEYBOARD = 1
    Private Type KEYBDINPUT
    wVk As Integer
    wScan As Integer
    dwFlags As Long
    time As Long
    dwExtraInfo As Long
    End Type
    Private Type GENERALINPUT
    dwType As Long
    xi(0 To 23) As Byte
    End Type
    Public Sub SendKey(bKey As Byte)
    Dim GInput(0 To 1) As GENERALINPUT
    Dim KInput As KEYBDINPUT
    KInput.wVk = bKey 'the key we're going to press
    KInput.dwFlags = 0 'press the key
    'copy the structure into the input array's buffer.
    GInput(0).dwType = INPUT_KEYBOARD ' keyboard input
    CopyMemory GInput(0).xi(0), KInput, Len(KInput)
    'do the same as above, but for releasing the key
    KInput.wVk = bKey ' the key we're going to realease
    KInput.dwFlags = KEYEVENTF_KEYUP ' release the key
    GInput(1).dwType = INPUT_KEYBOARD ' keyboard input
    CopyMemory GInput(1).xi(0), KInput, Len(KInput)
    'send the input now
    Call SendInput(2, GInput(0), Len(GInput(0)))
    End Sub
    </pre>

    then in your DTPicker's Enter event, use the following:
    <pre> SendKey VK_F4
    </pre>

    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  9. #9
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date & Time Picker (A2000 SR1)

    Brilliant.

    You must have spent some time on this.
    Using SendKey VK_F4 can I use if isnull:

    If IsNull then SendKey VK_F4

    Thank you very much Rory for your time & knowledge

    Dave

  10. #10
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Date & Time Picker (A2000 SR1)

    Dave,
    Yes you can though you'll probably need something like If IsNull(Me!DTPicker1) or Me!DTPicker1 = "" Then... to handle all eventualities.
    Admittedly, some simple SendKeys code would be easier but I have an irrational dislike of SendKeys!
    Regards,
    Rory

    Microsoft MVP - Excel

  11. #11
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date & Time Picker (A2000 SR1)

    Once again thanks

    Regards
    Dave

  12. #12
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Date & Time Picker (A2000 SR1)

    <hr> I have an irrational dislike of SendKeys<hr>
    Me too. And you can charge more for code that looks impressive! <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>
    Charlotte

  13. #13
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Date & Time Picker (A2000 SR1)

    Charge? I thought we did this out of the goodness of our hearts? <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Regards,
    Rory

    Microsoft MVP - Excel

  14. #14
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Date & Time Picker (A2000 SR1)

    Hey, you get what you pay for, right? I only volunteer here. I make my clients pay in the real world!
    Charlotte

Posting Permissions

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