Art-
It will call the function ONLY if both StartTime and EndTime are not null. Are you missing times in your records?
John Viescas, author
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)
-----------------------------------
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Art Lorenzini
Sent: Tuesday, March 20, 2012 4:21 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: Re: [MS_AccessPros] Invalid Use of Null error
John,
Well that solved the issue with the error but now it's not doing the calculation in txtElaspeTime.
With warm regards,
Arthur Lorenzini
Sioux Falls, South Dakota
________________________________
From: John Viescas <JohnV@msn.com>
To: MS_Access_Professionals@yahoogroups.com
Sent: Tuesday, March 20, 2012 10:12 AM
Subject: RE: [MS_AccessPros] Invalid Use of Null error
Art-
If either EndTime or StartTime is Null, that is what is causing the error. Try
this:
Private Sub Form_Load()
If Me.NewRecord Or IsNull(Me.EndTime) Or IsNull(Me.StartTime) Then
Me.txtElaspedTime = ""
Else
Me.txtElaspedTime = GetElapsedTime([EndTime] - [StartTime])
End If
End Sub
Private Sub Form_Current()
If Me.NewRecord Or IsNull(Me.EndTime) Or IsNull(Me.StartTime) Then
Me.txtElaspedTime = ""
Else
Me.txtElaspedTime = GetElapsedTime([EndTime] - [StartTime])
End If
End Sub
John Viescas, author
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)
---------------------------------
From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Art
Sent: Tuesday, March 20, 2012 3:59 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Invalid Use of Null error
I found this function for calculating elaspe time but when I move to a new
record I recieve a "Invalid Use of Null". I think I understanding th cause but I
am not sure how to fix it. Please advise.
Here is the code:
Function GetElapsedTime(interval)
Dim totalhours As Long, totalminutes As Long, totalseconds As _
Long
Dim days As Long, hours As Long, Minutes As Long, Seconds As Long
days = Int(CSng(interval))
totalhours = Int(CSng(interval * 24))
totalminutes = Int(CSng(interval * 1440))
totalseconds = Int(CSng(interval * 86400))
hours = totalhours Mod 24
Minutes = totalminutes Mod 60
Seconds = totalseconds Mod 60
GetElapsedTime = days & " Days " & hours & " Hours " & Minutes & _
" Minutes " & Seconds & " Seconds "
End Function
Private Sub Form_Load()
If Not Me.NewRecord Then
Me.txtElaspedTime = GetElapsedTime([EndTime] - [StartTime])
Else
Me.txtElaspedTime = ""
End If
End Sub
Private Sub Form_Current()
If Not Me.NewRecord Then
Me.txtElaspedTime = GetElapsedTime([EndTime] - [StartTime])
Else
Me.txtElaspedTime = ""
End If
End Sub
Thank you,
Arthur Lorenzini
Siooux Falls, SD
[Non-text portions of this message have been removed]
Selasa, 20 Maret 2012
RE: [MS_AccessPros] Invalid Use of Null error
__._,_.___
.
__,_._,___
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar