473,396 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Need help with clearing an error message" Invalid Null usage" in Access

"Hi there,

I am having a bit of a headache trying to get the following coding to work. What I am trying to accomplish is turn around totals between and open date and resolution date. My coding works fine if the fields are filled in, but how do I get the blank data set to zero so that I am not getting and error message?

Will using the Nz function eliminate this problem?

See Below....

This is the field from my query...
TimeElapsed: GetElapsedDays([ResolutionDate]-[OpenDate])

Field from Time elaspe function:

Function GetElapsedDays(interval)
Dim days As Long

days = Int(CSng(interval))
GetElapsedDays = days & " days "

End Function

Any suggestions will be greatly appreciated :)"
Mar 1 '07 #1
1 2059
ADezii
8,834 Expert 8TB
"Hi there,

I am having a bit of a headache trying to get the following coding to work. What I am trying to accomplish is turn around totals between and open date and resolution date. My coding works fine if the fields are filled in, but how do I get the blank data set to zero so that I am not getting and error message?

Will using the Nz function eliminate this problem?

See Below....

This is the field from my query...
TimeElapsed: GetElapsedDays([ResolutionDate]-[OpenDate])

Field from Time elaspe function:

Function GetElapsedDays(interval)
Dim days As Long

days = Int(CSng(interval))
GetElapsedDays = days & " days "

End Function

Any suggestions will be greatly appreciated :)"
The following code will work unless:
__1 You declare interval as any other Data Type other than Variant as in:
Public Function GetElapsedDays(interval As Long)
__2 You do not assign any Data Type other than Variant or String to the return value of the Function as in: Public Function GetElapsedDays(interval) As Long
__3 1 and 2 will not work under either condition. Just use the code below as it is and you'll be OK.
Expand|Select|Wrap|Line Numbers
  1. Public Function GetElapsedDays(interval)
  2. Dim days As Long
  3.  
  4. If IsNull(interval) Then
  5.   GetElapsedDays = "N/A"
  6. Else
  7.   days = Int(CSng(interval))
  8.   GetElapsedDays = days & " days "
  9. End If
  10. End Function
Mar 1 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: vincent wehren | last post by:
Hi, Trying to grasp Py_NewInterpreter()in a simple app embedding Python, I was wondering why the following gives me an error: int main() { PyThreadState *tstate; Py_Initialize();
3
by: Stephen Poley | last post by:
Could some kind soul explain the errors and warnings that the W3C CSS validator generates for page: http://www.atlis.nl/testsite/nl/ Results at: http://tinyurl.com/5pxqx The error "Invalid...
3
by: paul.furber | last post by:
Hi all, I have some code which looks a bit like this: #define Offset(m, T) ((size_t)(&((T *)1)->m) - 1) class Point: private: int *x,*y;
13
by: gary | last post by:
Hi, We all know the below codes are dangerous: { int *p = new int; delete p; delete p; } And we also know the compilers do not delete p if p==NULL. So why compilers do not "p = NULL"...
8
by: Owen Jenkins | last post by:
Hello. For years I've been using the DBEngine.CompactDatabase code to make backups of backend databases. But now I've struck a baffling problem where I get an Invalid Argument error. This...
0
by: Winterminute | last post by:
I am trying to read a list of install programs using WMI with ASP.NET/C#. However, it fails with "Invalid Class". I have confirmed that if I query LOCALHOST then it works fine, but if I query a...
0
by: Simon Harris | last post by:
I'm trying to access a password protected web service. My code is as follows: Dim BS7666 As New bs7666.BS7666 'New instance of my web service Dim CredCache As CredentialCache = New...
6
by: Patrick Dugan | last post by:
Hello, I'm trying to load different images (icons) into a PictureBox1.Image. The first image loads just fine, but the second image always returns the error "Invalid property used." It doesn't...
1
by: imranabdulaziz | last post by:
Dear All, I am using sql2005. i am writing stored procedure to save various master data . I recognize master by @type (input verible) and assign it to @mst veriable then based on @mst no I...
4
by: Mr Fuzzi | last post by:
Hi All, This morning I have installed and configured Apache, MySQL and PHP on a Windows Server 2003 machine. Everything appears to be working fine, except that I keep getting an error message...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.