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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

#Error in form's control

Status
Not open for further replies.

tekila

Programmer
Apr 18, 2002
150
SG
I've two textboxes on the form that are bound to TimeUp and TimeDown fields of a table. Both are in short time format and I've another textbox called Duration, which will calculate the difference in time between TimeUp and TimeDown in minutes.
The control source of Duration is: Abs(Int(CSng([TimeUp]-[TimeDown])*1440))). Duration textbox displays #Error in the form's preview. I've read up troubleshooting #Error in Access Help Index but couldn't find the fault. Why?
 


Hi

First you do have one too many parenthesis at the end

Abs(Int(CSng([TimeUp]-[TimeDown])*1440))

and secondly when I popped this into a quick query it worked fine ... try it as above


regards

jo
 
jo, I still get the #Error after pasting your expression in the control source.
 
Morning Tekila
To prove above works

create a query
add your table
add timeup to the first column
add timedown to the second
in the third copy below to the grid

Duration:Abs(Int(CSng([TimeUp]-[TimeDown])*1440))

run the query this will give you the minutes
What data type is Duration?

hope this helps

regards

jo

 
jo, it works in my query but the error appears in the form. Duration is a textbox that I created in the form with no data type defined.
 
Does anyone know how to tackle this?

 
Check the name of the control on the form. Make it unique and not the name of another control. This is just a guess but stranger things have happened
 
I managed to solve the problem; remove the expression in the control source of Duration and in the AfterUpdate events of both TimeUp and TimeDown, this is what I have:
************************************************************
Private Sub TimeDown_AfterUpdate()

If Not IsNull([TimeDown]) And Not IsNull([TimeUp]) Then
Me!Duration = Abs(Int(CSng([TimeUp] - [TimeDown]) * 1440))
Else
Me!Duration = Null
End If

End Sub
************************************************************

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top