Solved

"Invalid Use Of Null" using CDate

Posted on 2004-10-08
8
907 Views
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.

Suggestions?

Thanks,
Ed
0
Comment
Question by:MICHAED
[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
8 Comments
 
LVL 52

Assisted Solution

by:Ryan Chong
Ryan Chong earned 50 total points
ID: 12261748
try:

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

Assisted Solution

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

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

Author Comment

by:MICHAED
ID: 12261857
Hi,

I'm getting "Invalid Operator" so I'm trying to find the expression's error....
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 11

Expert Comment

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

Author Comment

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

Author Comment

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

Accepted Solution

by:
shanesuebsahakarn earned 150 total points
ID: 12262000
Try:

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

Author Comment

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

Ed
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

728 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