DateTimePicker Control Events

J

jille

Hi,

I'm using a DateTimePicker in a Word 2000 userform and want to run a
procedure once a date is chosen. I'm currently using the Change event but
find that it is a problem in that the routine runs when you're in the process
of navigating around the calendar instead of when the user finishing making a
selection.

I checked for other events and found some but wasn't sure which I can/should
use in Word. Any suggestions? fyi, I found a control.leave,
control.lostfocus and a datetimepicker.valuechanged event and don't
understand the parameters!

Thanks
 
A

Anand.V.V.N

Hi
There is a event in the datetime picker called closeup, I think if you write
your code in the closeup event it should solve your problem.

Anand.V.V.N
 
J

jille

I totally get the example code, but haven't dealt with event handlers before
so the following declaration/usage code leaves me cold. Can you help?

Visual Basic (Declaration)
Public Event CloseUp As EventHandler

Visual Basic (Usage)
Dim instance As DateTimePicker
Dim handler As EventHandler

AddHandler instance.CloseUp, handler

FYI, I tried declaring the public event but got an error...is it
 
S

Shauna Kelly

Hi jille

It's not as hard as it looks. In the code of your form, at the top left of
the code window, there's a drop down box that lists all the controls on your
form. Choose your date picker in that list.

Now, in the drop down box at the top right, choose CloseUp.

Word will insert the appropriate code. If your datepicker is named, say,
dtpStart then the code will look like

Private Sub dtpStart_CloseUp()

End Sub

You can put whatever you like between the two lines of code Word provides.
For example:

Private Sub dtpStart_CloseUp()
MsgBox "You chose " & Me.dtpStart.Value
End Sub

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top