By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,705 Members | 1,815 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,705 IT Pros & Developers. It's quick & easy.

Code to validate StartDate and EndDate

P: n/a
What is the code to do the following --

If txtEndDate < txtStartDate
txtEndDate = null
txtEndDate setfocus
End If

Also, what event should the code be in?

Thanks!

Mark
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Mark wrote:
What is the code to do the following --

If txtEndDate < txtStartDate
txtEndDate = null
txtEndDate setfocus
End If
That. Only put a dot (.) between txtEndDate and setfocus.
Also, what event should the code be in?


I think it needs to be called both when enddate and startdate change.
Create AfterUpdate events for both controls, and call a common procedure
from them. The common procedure can be called catchDates and will
contain your code.
--
Bas Cost Budde
http://www.heuveltop.nl/BasCB

Nov 12 '05 #2

P: n/a
Mark,

If Me.txtEndDate < Me.txtStartDate
Msgbox "End Date cannot be earlier than Start Date"
Me.txtEndDate = null
Me.txtEndDate.SetFocus
End If

I have added a message box to alert the user as to what they are doing
wrong, and why their entry disappeared.

Regularly, a user would first enter start date, then end date (you can also
guide them that way by means of relative position and tab order). So, I
guess you could use the on change event of the end date textbox.

HTH,
Nikos

"Mark" <mm*****@earthlink.net> wrote in message
news:Ry******************@newsread3.news.atl.earth link.net...
What is the code to do the following --

If txtEndDate < txtStartDate
txtEndDate = null
txtEndDate setfocus
End If

Also, what event should the code be in?

Thanks!

Mark

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.