Solved

Invalid Use of Null

Posted on 2006-07-08
4
698 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
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…
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…

685 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