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

x
?
Solved

MS DateTime Picker?

Posted on 2002-03-20
3
Medium Priority
?
363 Views
Last Modified: 2008-03-06
How does the On Upated Event on the MS DateTime Picker get triggered?

I can't seem to trigger it by changing or morving out of the control.

0
Comment
Question by:eeevbeee
[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
  • 2
3 Comments
 
LVL 2

Expert Comment

by:Syed Irtaza Ali
ID: 6884795
well its better to use On Change event instead of on updated.

And use DateDiff  function to validate the date selected.

Nomi.
0
 

Author Comment

by:eeevbeee
ID: 6884856
nomehero

On Change triggers ever time it's changed even I the user didn't leave the control, and I want it to trigger only after that. A before Update would even better, but I don't see that as well.

How could I use Datediff, where would i get the Before date?

0
 
LVL 2

Accepted Solution

by:
Syed Irtaza Ali earned 100 total points
ID: 6887912
I was having the same problem with checks on 2 DT-Pickers and this was the solution I came up with.

Private Sub Form_BeforeUpdate(Cancel As Integer)
If DateDiff("d", Nz(NextDate, ""), Nz(LastDate, "")) > 0 Then
    MsgBox "The next service date cannot occur before last service date.", vbInformation, "MyProgram"
    LastDate = Now()
    NextDate = Now()
    Cancel = True
End If
End Sub

'''''for
Private Sub LastDate_GotFocus()
'''''AND Private Sub LastDate_LostFocus()
'''''write this code
If DateDiff("d", Nz(NextDate, ""), Nz(LastDate, "")) > 0 Then
    MsgBox "The last service date cannot occur after next service date.", vbInformation, "MyProgram"
    LastDate = Now()
    NextDate = Now()
End If
End Sub

'''''for
Private Sub NextDate_GotFocus()
''''''AND Private Sub NextDate_LostFocus()
''''''write this code
If DateDiff("d", Nz(NextDate, ""), Nz(LastDate, "")) > 0 Then
    MsgBox "The next service date cannot occur before last service date.", vbInformation, "MyProgram"
    LastDate = Now()
    NextDate = Now()
End If
End Sub


The updated and Change event used to bypass the checks (ie didnt run the events) and the lastdate could be saved as a greater date than Nextdate. These controls are bound. So I made checks on the Lostfocus and gotfocus and in the end one check was made on the Form_BeforeUpdate so that I could restrict the user on selecting the invalid dates.


Nomi.

0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

704 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