Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Aug 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Date and Time Picker Enabled Property (2002 SP3)

    Hi All,

    I have the following problem. I have on a form amongst other controls the ms Date and Time picker. If I change the enabled property to false, the control whites out it current location and repositions itself in the top left corner of the form. Upon enabling the DTPicker it then returns to its oringal position. What is going on? Can anyone shed some light on this?????

    Thanks Glenn

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

    Re: Date and Time Picker Enabled Property (2002 SP3)

    Hmmmmmmm

    I see what you mean.
    I reproduced this, but it only moved to the top left in design view and only when clicked or selected in design.

    What is it you're trying to do with the control, there may be an alternative way?

  3. #3
    New Lounger
    Join Date
    Aug 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date and Time Picker Enabled Property (2002 SP3)

    Hi Dave,

    Thanks for your time! I want to be able to disable the control so the user cannot enter a date on the form when a new record is selected. I guess I could set the visible property to false but would prefer to just have the control 'greyed' out (Disabled). I have this problem with the control only during run time and not in design mode.

    Cheers G

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

    Re: Date and Time Picker Enabled Property (2002 SP3)

    Glenn

    I stopped using the D&T picker a while ago, it caused so many problems.
    I think also, on distribution of databases once changed to a runtime with the developer disc's, the control doesn't work.

    I now use the MSCAL control (My version is 7) which doesn't cause me any issues.
    You can attach it to a pop up form and call it whenever needed, or just place it on the main form.
    I'm sure it's far more controllable than D&T Picker.

    Why your control should move when disabled, I really don't know.

  5. #5
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Date and Time Picker Enabled Property (2002 SP3)

    Don't know why control moves when enabled or disabled. I agree these controls are flakey and do not use them. Experimenting with it on Access 2K form, the only way I was able to prevent flakey behavior was by storing control's position on form (Left & Top properties) in variables, then resetting properties when control enabled. Sample code from form module:

    <code>Option Explicit</code>

    <code>Private DTP As MSComCtl2.DTPicker</code>
    <code>Private sglLeft As Single</code>
    <code>Private sglTop As Single</code>

    <code>Private Sub Form_Open(Cancel As Integer)</code>
    <code> Set DTP = Me.Controls("ActiveXCtl1").Object</code>
    <code> sglLeft = Me.ActiveXCtl1.Left</code>
    <code> sglTop = Me.ActiveXCtl1.Top</code>
    <code>End Sub</code>

    <code>Private Sub Command1_Click()</code>
    <code> ' Me.ActiveXCtl1.Enabled = False</code>
    <code> DTP.Enabled = False</code>
    <code>End Sub</code>

    <code>Private Sub Command2_Click()</code>
    <code> ' Me.ActiveXCtl1.Enabled = True</code>
    <code> ' Calling DTPicker property directly did not change flakey behavior:</code>
    <code> DTP.Enabled = True</code>
    <code> Me.ActiveXCtl1.Left = sglLeft</code>
    <code> Me.ActiveXCtl1.Top = sglTop</code>
    <code>End Sub</code>

    <code>Private Sub Form_Unload(Cancel As Integer)</code>
    <code> Set DTP = Nothing</code>
    <code>End Sub</code>

    Note in my case, it was when control was enabled that it moved to top corner of form. To be safe reset Left & Top for both enable & disable commands. Also, used an object variable specifically referencing the Date Time Picker, initialized when form opens, so you can call the custom ActiveX properties directly with Intellisense in code module. However, setting Enabled property, whether using:

    <code> Me.ActiveXCtl1.Enabled = True</code>
    (or)
    <code> DTP.Enabled = True</code>

    Still got flaky results. Recommend try method above to prevent repositioning on form, or get rid of DT Picker altogether. Code used above worked OK in test.

    HTH

Posting Permissions

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