473,385 Members | 1,919 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,385 software developers and data experts.

Date Validation

3
Okay, I have a text box which has the following date format dd/mm/yyyy but i want it so that the user cannot input a date which has already passed and not todays date.

So its the 28th today, so a user would only be able to choose 29th onwards.

Thanks for this
Mar 28 '11 #1
1 857
TheSmileyCoder
2,322 Expert Mod 2GB
Hi Exsert.

What you need to look at is the BEFORE_Update event of your control. Assuming your CONTROL is named tb_Date (tb short for textbox):
Expand|Select|Wrap|Line Numbers
  1. Private Sub tb_Date_BeforeUpdate(Cancel as Integer)
  2.   If Isnull(Me.tb_Date)
  3.     'Nothing was entered, or value allready there was deleted
  4.     Exit Sub
  5.   End If
  6.   If Not IsDate(me.tb_Date) Then
  7.     Msgbox "The program did not recognize your entry as a valid Date"
  8.     Cancel=True
  9.     Exit Sub
  10.   End If
  11.   If Date>=Me.Tb_Date then
  12.     Msgbox "You cannot select todays date, or a date that has allready passed"
  13.     Cancel=True
  14.     Exit Sub
  15.   End If
  16.  
  17. End Sub
PLEASE take the time to understand what the code is doing, and learn from it, instead of blindly copying it. If you have questions, please ASK.
Mar 28 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

30
by: Dr John Stockton | last post by:
It has appeared that ancient sources give a method for Numeric Date Validation that involves numerous tests to determine month length; versions are often posted by incomers here. That sort of code...
14
by: Steve Wright | last post by:
I am trying to validate if an entry on a form is a date. I have adapted code I found here http://www.codingforums.com/archive/index.php/t-14325 as below but I can't seem the get the results that I...
11
by: Diego | last post by:
Hi all a quick question: how can I validate a date in asp.net (2.0) with c#? I didn't find a quick anwer. Thanks, Diego.
3
by: LDD | last post by:
Are there any built in time and/or date validation methods that one can make use of in .NET? thanks folks LDD
3
by: pmarisole | last post by:
The following javascript code gives me the date validation that I need except after the correct date is entered into the field, it puts the date in the wrong format EXAMPLE: User enters...
2
by: John Smith | last post by:
Hello, I have a VB.NET application with a Windows form that have several textboxes fields where I have dates entered. I would like to do a date validation check after the the field is updated, so...
1
by: jsredhar | last post by:
Dear Experts, I have two text boxes in my form (f1) i'm prompting the users to select the date from callender which is embeded within the from. when the users Pick the date from the calender.it...
8
pradeepjain
by: pradeepjain | last post by:
<script language = "Javascript"> /** * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/) */ // Declaring valid date character, minimum year and maximum...
5
Stang02GT
by: Stang02GT | last post by:
I have been asked to validate a date on our web-page so that people cannot enter dates like 14/1/08 or 2/30/06. I have found code that will do exactly what i need it to do, but i am not sure how to...
2
by: mshroom12 | last post by:
I am having trouble with the following project on hand. I use Eclipse to do my work in Java. This is what I'm supposed to complete. Date Validation In this exercise you will write a program...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.