Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / November 2005

Tip: Looking for answers? Try searching our database.

Date validation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Samantha - 08 Nov 2005 22:07 GMT
Hi,
I have a textbox on a form used  to capture the start date used as a
parameter for a query.  I want to validate that the date is valid. For
example, Feb 29, 2005 is invalid, and currently it breaks the sql code. Is
there a way to check the date in the textbox before executing the query?
thanks in advance for any assistance.
Ofer - 08 Nov 2005 22:20 GMT
Try this

On the before update event of the Text field write the code
=======================================
On error goto MySub_Error
Dim MyDate
' If the cvdate will get an error it will prompt the user with a message
MyDate = CvDate(Me.[TextFieldName])
Exit Sub

MySub_Error:
  msgbox "Error in date"
  cancel = True  'wont let the user exit the field
==================================
Signature

The next line is only relevant to Microsoft''s web-based interface users.
If I answered your question, please mark it as an answer. It''s useful to
know that my answer was helpful
HTH, good luck

> Hi,
> I have a textbox on a form used  to capture the start date used as a
> parameter for a query.  I want to validate that the date is valid. For
> example, Feb 29, 2005 is invalid, and currently it breaks the sql code. Is
> there a way to check the date in the textbox before executing the query?
> thanks in advance for any assistance.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.