Solved

MS DateTime Picker?

Posted on 2002-03-20
3
359 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 25 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

830 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