Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with If then else coding

Status
Not open for further replies.

sdimaggio

Technical User
Jan 23, 2002
138
US
I'm having trouble closing an If statement.

I wrote a function to change short time to minutes.

Function TimeToMin(MyTime)
TimeToMin = CInt(CDbl(MyTime) * 24 * 60)
End function

This works fine when there is a short time in the field.

However, some of my time fields in the table are NULL and i'm getting an error.

I changed the function to use an If then else, but i'm having trouble. What is wrong here?

Function TimeToMin(MyTime)
If MyTime Is Null Then TimeToMin = 0
Else
TimeToMin = CInt(CDbl(MyTime) * 24 * 60)
End If
End Function
 
Hi!

Try this:

Function TimeToMin(MyTime)
If IsNull(MyTime) Then
TimeToMin = 0
Else
TimeToMin = CInt(CDbl(MyTime) * 24 * 60)
End If
End Function

hth
Jeff Bridgham
bridgham@purdue.edu
 
Hi!

Your Welcome! :)

Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top