Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MS DateTime Picker?

Posted on 2002-03-20
3
Medium Priority
?
368 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
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

963 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