Solved

Date Validation and accepting null values on Access Forms

Posted on 2014-03-21
3
276 Views
Last Modified: 2014-06-06
Hi

I have an issue with some code behind a form, which previously worked but seem to break now.  The 3 dates on the form are defaulted and users can also manually edit it too in the field directly.  The 3 dated validate each other and the recording date has to be between the time started and time signed.

(1) Seems to be a problem with with dates manually entered through the input mask for DD/MM/YYYY HH:MM  ie 99\99\9999/99:99:0...  The criteria berow fails as macro cannot recognise a date format.

(2)  If I insert a CDate() for each field return, there will be a problem dealing with Null Values which should be accepted

Is there a better way of running these validations and also ignoring null values?

'If Me.txtTimeRecorded <> "" Then
'    If Me.txtTimeRecorded < Me.txtTimeStarted Then
'            MsgBox ("The Recorded Time can not be before the Start Time")
'            blnexit = True
'    End If
'    If Me.txtTimeRecorded > Me.txtTimeSigned Then
'            MsgBox ("The Recorded Time can not be after the Time Signed")
'            blnexit = True
'    End If
'End If
0
Comment
Question by:yasanthax
  • 2
3 Comments
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 300 total points
ID: 39945037
Use CVDate in place of CDate. It accepts Nulls.

/gustav
0
 

Author Closing Comment

by:yasanthax
ID: 40116963
Thanks.  I did not know about this function and seems to fix it.
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 40116966
You are welcome!

/gustav
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

808 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