Solved

Date Validation and accepting null values on Access Forms

Posted on 2014-03-21
3
279 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 50

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 50

Expert Comment

by:Gustav Brock
ID: 40116966
You are welcome!

/gustav
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

726 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