+ Reply to Thread
Results 1 to 2 of 2

How to control "Date Time Picker ActiveX Control"

  1. #1
    Jafery
    Guest

    How to control "Date Time Picker ActiveX Control"

    Hi there,

    I have a problem with DTPicker Control ,the code below, I cannot set the
    value back
    to call back event....when user click cancel button. How can I fix this
    problem?

    Thanks
    Jafery

    ----------Here is my code-----------------------------
    Private Sub cmdCancel_Click()
    dtDasof.Value = CallbackDate
    ThisWorkbook.Worksheets("Main").Activate
    Range("B2").Select
    ActiveCell.Formula = dtDasof.Value
    frmSetup.Hide
    End Sub

    Private Sub cmdOK_Click()
    ThisWorkbook.Worksheets("Main").Activate
    Range("B1").Select
    ActiveCell.Formula = dtDasof.Value
    frmSetup.Hide
    End Sub

    Private Sub dtDasof_CallbackKeyDown(ByVal KeyCode As Integer, ByVal Shift As
    Integer, ByVal CallbackField As String, CallbackDate As Date)
    dtDasof.Cancel = True
    CallbackDate = dtDasof.Value
    End Sub


  2. #2
    Dave Peterson
    Guest

    Re: How to control "Date Time Picker ActiveX Control"

    I think I'd drop that selects and activates:

    Private Sub cmdCancel_Click()
    dtDasof.Value = CallbackDate
    ThisWorkbook.Worksheets("Main").Range("B2").value = dtDasof.Value
    frmSetup.Hide
    End Sub

    Private Sub cmdOK_Click()
    ThisWorkbook.Worksheets("Main").Range("B1").value = dtDasof.Value
    frmSetup.Hide
    End Sub

    Private Sub dtDasof_CallbackKeyDown(ByVal KeyCode As Integer, ByVal Shift As
    Integer, ByVal CallbackField As String, CallbackDate As Date)
    dtDasof.Cancel = True
    CallbackDate = dtDasof.Value
    End Sub

    I'm guessing that your code is in a worksheet module (but not main's).

    When you have unqualified ranges in your code, it refers to the worksheet owning
    the code--not the activesheet.

    This behavior is different than what you find in a general module.



    Jafery wrote:
    >
    > Hi there,
    >
    > I have a problem with DTPicker Control ,the code below, I cannot set the
    > value back
    > to call back event....when user click cancel button. How can I fix this
    > problem?
    >
    > Thanks
    > Jafery
    >
    > ----------Here is my code-----------------------------
    > Private Sub cmdCancel_Click()
    > dtDasof.Value = CallbackDate
    > ThisWorkbook.Worksheets("Main").Activate
    > Range("B2").Select
    > ActiveCell.Formula = dtDasof.Value
    > frmSetup.Hide
    > End Sub
    >
    > Private Sub cmdOK_Click()
    > ThisWorkbook.Worksheets("Main").Activate
    > Range("B1").Select
    > ActiveCell.Formula = dtDasof.Value
    > frmSetup.Hide
    > End Sub
    >
    > Private Sub dtDasof_CallbackKeyDown(ByVal KeyCode As Integer, ByVal Shift As
    > Integer, ByVal CallbackField As String, CallbackDate As Date)
    > dtDasof.Cancel = True
    > CallbackDate = dtDasof.Value
    > End Sub


    --

    Dave Peterson

+ 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