Solved

Date Validation and accepting null values on Access Forms

Posted on 2014-03-21
3
271 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now