Solved

"Invalid Use Of Null" using CDate

Posted on 2004-10-08
8
902 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
8 Comments
 
LVL 50

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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
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 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…

808 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