Solved

Invalid Use of Null

Posted on 2006-07-08
4
671 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
ID: 17066696
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
ID: 17066700
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
ID: 17066914
aikimark,
Your code works fine.

Regards
Bill
0
 
LVL 4

Author Comment

by:billcute
ID: 17066953
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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…

912 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

23 Experts available now in Live!

Get 1:1 Help Now