473,324 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Code to validate StartDate and EndDate

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
2 1700
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: JP SIngh | last post by:
Hi All I am trying to plot the days off employees have taken in the selected month visually using the following code. The code below takes a long time to execute typically about 8-15 secs each...
4
by: cotton_gear | last post by:
Hello, I need to add some javascript code block dynamically to a web page. I looked into the various postings at various groups but none seems to be solving my problem. Among the approaches...
5
by: deercreek | last post by:
I could use a little help from a good code writer out there. I found some code and modified it a bit for my needs but, I need a little help to finish it up. What I am trying to due is to get a...
5
by: Eugenio | last post by:
Hello everyone. I've been working on a database in MSAccess2007 and had to convert it to 2003. I have a line of code which returns a requested date range from a query to a listbox: Dim MySQL...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.