Solved

Invalid Use of Null

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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…

752 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