Help with calculation

Cobra

Registered User.
Local time
Today, 09:35
Joined
Dec 8, 2008
Messages
20
Some people helped me get my "if" statement working for this code here:

If Me.No_takeoff = -1 Then
TxtLaunch.Value = "No Takeoff"
Me.TxtLand = TimeValue(Now)
TxtLand.SetFocus
Else
If Me.No_takeoff = 0 Then
Me.TxtLand = TimeValue(Now)
TxtLand.SetFocus
TxtTotal.Value = (TxtLand.Value - TxtLaunch.Value)
End If
End If

However, now the "TxtTotal.Value = (TxtLand.Value - TxtLaunch.Value)" doesn't work as I had to change the data type for that field in the table from date/time to text as I wanted to add the "No takeoff" function. It now comes up with "Type Mismatch" even though all 3 columns are set to text and have the same properties.. It used to work fine when I had the data type as Date/Time and not the If statement ^^

What did I do :P
 
although you can add times mathematically) you cant add text entries

you could try

TxtTotal.Value = (cdate(TxtLand.Value) - cdate(TxtLaunch.Value))

which changes the values to dates before adding them - but i think you will have to do some further massaging to handle the non-time strings
 
That seems the sort of thing I'm looking for but it comes up with a strange number that isn't correct when I do it :(
 
Try

cdate(TxtTotal.Value) = (cdate(TxtLand.Value) - cdate(TxtLaunch.Value))

but even so date/time arithmetic ends up not being that simple on many occasions.

Brian
 

Users who are viewing this thread

Back
Top Bottom