Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DTPicker doesn't fire change event

Posted on 2001-07-02
15
Medium Priority
?
1,584 Views
Last Modified: 2010-08-05
Hello Experts.

I'm developing with vb6 (SP3).
I have a DTPicker-Control included in MSCOMCT2.OCX (v.6.00.8418)

placed on a Form.

Code to reproduce behaviour:

Private Sub DTPicker1_Change()
    MsgBox "Date changed !"
End Sub


Private Sub Form_Load()
    DTPicker1.Value = "21.04.1997"
    DTPicker1.Value = "02.02.2000"
End Sub

... but no MsgBox appears !

 
0
Comment
Question by:VK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 2
  • +3
15 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 6244938
It would appear that this event is only fired when the control's value is changed by the control itself and not through code!
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 6244953
Hi VK,

Try to modify the

Private Sub Form_Load()
   DTPicker1.Value = "21.04.1997"
   DTPicker1.Value = "02.02.2000"
End Sub

to

Private Sub Form_Load()
   DTPicker1.Value = "21/04/1997" 'Or "21-04-1997"
   DTPicker1.Value = "02/02/2000" 'Or "02-02-2000"
End Sub

And try again.

The sub

Private Sub DTPicker1_Change()
   MsgBox "Date changed !"
End Sub

is tested ok.
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 6244976
Hi,

in your Form_load()

change

DTPicker1.Value = "21.04.1997"

to

DTPicker1.Value = CDate("21-04-1997")
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Expert Comment

by:Onkar
ID: 6245012
Hi,

When you assign vlue to DTPicker change event will not fire. Once you select a date from the DTPicker then it fires change event "DTPicker1_Change"

Onkar
0
 
LVL 6

Author Comment

by:VK
ID: 6245046
I know that the event fires when i change the value of the DTPicker from GUI, but i have to do it from code. Calling
Call DTpicker1_Change is not elegant.
0
 
LVL 6

Author Comment

by:VK
ID: 6245054
I know that the event fires when i change the value of the DTPicker from GUI, but i have to do it from code. Calling
Call DTpicker1_Change is not elegant.
0
 
LVL 6

Author Comment

by:VK
ID: 6245063
I know that the event fires when i change the value of the DTPicker from GUI, but i have to do it from code. Calling
Call DTpicker1_Change is not elegant.
0
 
LVL 6

Author Comment

by:VK
ID: 6245071
Thanks for so much reply, but

DTPicker1.Value = CDate("21-04-1997")

AND

DTPicker1.Value = "21/04/1997" 'Or "21-04-1997"
DTPicker1.Value = "02/02/2000" 'Or "02-02-2000"

doesn't work !

It's not a formatting problem i think !

0
 
LVL 3

Accepted Solution

by:
nigelrowe earned 200 total points
ID: 6245130
Event Change()
    Member of MSComCtl2.DTPicker
    Occurs when the user selects a new date or changes a date in the edit portion of the control.

(VB object browser)
0
 
LVL 6

Author Comment

by:VK
ID: 6245154
It's not the solution, but it is the best answer describing the reason why.

Ty
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6245164
VK, sometimes we have to take the inelegant solution when there is no alternative. In this case I think that there is no alternative as the only way I have found to get the change event to fire is by using the GUI control itself. Even the CCRP date time picker control which in some ways is a better control exhibits the same behaviour in respect of the change event when the value is set in code.

I guess you will just have to call the change event in code (or perhaps a nicer solution would be to move the code from the change event to a seperate sub/function and call this directly - and from the change event sub as well).
0
 
LVL 3

Expert Comment

by:nigelrowe
ID: 6245306
Yes, not much of a solution was it? Tim Coffee is right, you don't seem to have much of a choice here. Cheers and good luck.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 6245380
one lump of sugar or two Tim Coffee?
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6245434
Two please and a shot of Irish Whiskey as well thanks Azra!
0
 
LVL 6

Author Comment

by:VK
ID: 6247451
Ty TimCottee and AzraSound for the good resonance. Next time if i'm unsure whom to give the points Tim would get them :-).

Cu
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question