Solved

MS DateTime Picker?

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

914 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now