If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
#Error in date field
Hi everyone,
I would be grateful if someone could tell me how to handle errors in queries. The problem is that I am using DateAdd function to add up a number to the date so for eg: DateCleared = 12/01/2004 Length_of_Level = 2 So i have used the following: Date Renewal: DateAdd("yyyy",[Length_of_ Level],[DateCleared])-1 The formula adds up the date and substracts one day...so the final result would be 11/01/2006 and it works fine. But if either the dateCleared or Length_of_Level is missing it results in #Error in the field but I want it to be blank and not say anything in the field if such information is missing. Please bear in mind that I don't want to use VBA code as i'm still a beginner and not too good with VB code and therefore appreciate it if you can help me with it in Query itself. Thanks in advance |
#2
|
|||
|
|||
Try something like:
Date Renewal: IIf(IsNull([Length_of_ Level]+[DateCleared]), Null, DateAdd("yyyy",[Length_of_ Level],[DateCleared])-1) -- Duane Hookom MS Access MVP "Kushum" wrote in message ... Hi everyone, I would be grateful if someone could tell me how to handle errors in queries. The problem is that I am using DateAdd function to add up a number to the date so for eg: DateCleared = 12/01/2004 Length_of_Level = 2 So i have used the following: Date Renewal: DateAdd("yyyy",[Length_of_ Level],[DateCleared])-1 The formula adds up the date and substracts one day...so the final result would be 11/01/2006 and it works fine. But if either the dateCleared or Length_of_Level is missing it results in #Error in the field but I want it to be blank and not say anything in the field if such information is missing. Please bear in mind that I don't want to use VBA code as i'm still a beginner and not too good with VB code and therefore appreciate it if you can help me with it in Query itself. Thanks in advance |
#3
|
|||
|
|||
Hi Duane,
Thankyou so much for your help I appreciate it...it works fine.. "Duane Hookom" wrote: Try something like: Date Renewal: IIf(IsNull([Length_of_ Level]+[DateCleared]), Null, DateAdd("yyyy",[Length_of_ Level],[DateCleared])-1) -- Duane Hookom MS Access MVP "Kushum" wrote in message ... Hi everyone, I would be grateful if someone could tell me how to handle errors in queries. The problem is that I am using DateAdd function to add up a number to the date so for eg: DateCleared = 12/01/2004 Length_of_Level = 2 So i have used the following: Date Renewal: DateAdd("yyyy",[Length_of_ Level],[DateCleared])-1 The formula adds up the date and substracts one day...so the final result would be 11/01/2006 and it works fine. But if either the dateCleared or Length_of_Level is missing it results in #Error in the field but I want it to be blank and not say anything in the field if such information is missing. Please bear in mind that I don't want to use VBA code as i'm still a beginner and not too good with VB code and therefore appreciate it if you can help me with it in Query itself. Thanks in advance |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Import date field problem. | Thief_ | General Discussion | 1 | July 18th, 2005 10:11 AM |
date ranges from a calculated date field | John Feeley | Running & Setting Up Queries | 1 | May 26th, 2005 06:53 AM |
Rowsource of Field List | Mark | Using Forms | 5 | December 20th, 2004 12:42 AM |
How do I set up a report using dates as my report header? | Robin | Setting Up & Running Reports | 16 | November 13th, 2004 01:00 PM |
Filtering on custom date field | MED | Contacts | 3 | September 17th, 2004 03:05 PM |