Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


"Invalid Use Of Null" using CDate

Posted on 2004-10-08
Medium Priority
Last Modified: 2008-02-01
Hi All,

I have a date/time field in a table which is converted within a query from a string value via the following:

New Date Field: Int(CDate([Original Date Field]))

The problem is, I cannot view the query in design view if any records do not have data within the date field -- I get a "Invalid Use Of Null" error message.  This field will not always contain data, therefore, I need some way to work around this.


Question by:MICHAED
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
LVL 53

Assisted Solution

by:Ryan Chong
Ryan Chong earned 200 total points
ID: 12261748

New Date Field: IIF(IsDate([Original Date Field]) ,  Int(CDate([Original Date Field])) , 0)
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 200 total points
ID: 12261852

New Date Field: IIF(([Original Date Field])Is Null ,"",  Int(CDate([Original Date Field])))

Author Comment

ID: 12261857

I'm getting "Invalid Operator" so I'm trying to find the expression's error....
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

LVL 11

Expert Comment

ID: 12261869
Alternatively, you can avoid the IIF function by using:
     Format(Nz([Original Date Field], ""), "mm/dd/yy")

Author Comment

ID: 12261945
Jokra, will your function convert my date/time field ...or leave it as a string?

Author Comment

ID: 12261978
Folks, I've tried all suggestions -- and I do not get the error anymore.  However, the sort order is appears that the field is sorting like a string field rather than a date field.
LVL 41

Accepted Solution

shanesuebsahakarn earned 600 total points
ID: 12262000

New Date Field: IIf(IsNull([Original Date Field]),Null,Int(CDate([Original Date Field])))

Author Comment

ID: 12262032
Shane's version worked -- thanks all!


Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

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.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

670 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