Solved

Invalid Use of Null

Posted on 2006-07-08
4
655 Views
Last Modified: 2009-07-29
I sometimes get the Run time error 94 - invalid use of Null

Private Sub txtDOB_AfterUpdate()
  Me.txtDOB = CDate(Me.txtDOB))
End Sub
' *****

I changed the code to the one below the error disappear but I am not too sure if this was the right code.

 Me.txtDOB = CDate(Nz(Me.txtDOB))
0
Comment
Question by:billcute
  • 2
4 Comments
 
LVL 44

Expert Comment

by:GRayL
Comment Utility
You have to remember that while a date can be null, the function Cdate always has to work off a number.  
CDate(null) will always yield an error message.
0
 
LVL 45

Accepted Solution

by:
aikimark earned 125 total points
Comment Utility
1. if this is a bound control, MSAccess will not allow non-date data to be entered.
2. proper protective code example:
Private Sub txtDOB_AfterUpdate()
  If IsNull(Me.txtDOB) Then
  Else
    Me.txtDOB = CDate(Me.txtDOB))
  End If
End Sub
0
 
LVL 4

Author Comment

by:billcute
Comment Utility
aikimark,
Your code works fine.

Regards
Bill
0
 
LVL 4

Author Comment

by:billcute
Comment Utility
GrayL / aikimark,
If you have time, I will appreciate it if you can take a look at some of my other posts that are currently open.

Regards
Bill
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

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

12 Experts available now in Live!

Get 1:1 Help Now