Solved

MS DateTime Picker?

Posted on 2002-03-20
3
353 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
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…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

16 Experts available now in Live!

Get 1:1 Help Now