Convert Long Time to double

P

Paul3rd

Hello,
On a form I have two text boxes that contain different times, the text boxes
are formatted as Long Time.
Text114 is the system time. JETime is a time stamp.
I need to convert these two long times to doubles so I can compare the values.
Something like:

Dim NTime As Double
Dim JET As Double


NTime = CDbl(Me.Text114.Value)
JET = CDbl(Me.JETime.Value)

If NTime > JET Then
Me.Text114.ForeColor = vbRed
End If

Or, am I completely off base using the CDbl function?
Can anyone provide help?
Thanks in advance,
Paul
 
J

Jeff Boyce

MS Access doesn't have a "Long Time" data type. It does have a format with
that title, but formatting doesn't change the underlying data stored in a
Date/Time field.

If both those textboxes are bound to fields that are Date/Time data type
fields, you can compare them without conversion.

What happens when you try to compare them?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
P

Paul3rd

Hello Jeff,
Sorry it took so long to get back to you,
Neither of the text boxes is bound (Text114) gets is value from Me.Text114 =
NOW. JETime gets it's value from the expression: =[TechTime](another time
stamp) +([FlatRate](a user input)*.042).
I have been able to use the following code in the forms timer event to
accomplish the same thing:
If DateDiff("S", Me.JETime, Me.Text114) > 10 Then
Me.Text114.ForeColor = vbRed
End If
I never could come up with any code that would work in the On Change event
of a control. (Which was my original intention)
Paul
 
J

Jeff Boyce

Paul

"Now()" is not the same as "Date()".

Now() generates a date/time value, while Date() records the date (actually,
midnight of the date).

If you are comparing dates, you need to be working with dates
(?DateValue()).

Or am I still not understanding?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Paul3rd said:
Hello Jeff,
Sorry it took so long to get back to you,
Neither of the text boxes is bound (Text114) gets is value from Me.Text114
=
NOW. JETime gets it's value from the expression: =[TechTime](another time
stamp) +([FlatRate](a user input)*.042).
I have been able to use the following code in the forms timer event to
accomplish the same thing:
If DateDiff("S", Me.JETime, Me.Text114) > 10 Then
Me.Text114.ForeColor = vbRed
End If
I never could come up with any code that would work in the On Change event
of a control. (Which was my original intention)
Paul

Jeff Boyce said:
MS Access doesn't have a "Long Time" data type. It does have a format
with
that title, but formatting doesn't change the underlying data stored in a
Date/Time field.

If both those textboxes are bound to fields that are Date/Time data type
fields, you can compare them without conversion.

What happens when you try to compare them?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
P

Paul3rd

Hello Jeff,
I'm trying to compare time values. I've got the code working correctly now.
Thanks,
Paul

Jeff Boyce said:
Paul

"Now()" is not the same as "Date()".

Now() generates a date/time value, while Date() records the date (actually,
midnight of the date).

If you are comparing dates, you need to be working with dates
(?DateValue()).

Or am I still not understanding?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Paul3rd said:
Hello Jeff,
Sorry it took so long to get back to you,
Neither of the text boxes is bound (Text114) gets is value from Me.Text114
=
NOW. JETime gets it's value from the expression: =[TechTime](another time
stamp) +([FlatRate](a user input)*.042).
I have been able to use the following code in the forms timer event to
accomplish the same thing:
If DateDiff("S", Me.JETime, Me.Text114) > 10 Then
Me.Text114.ForeColor = vbRed
End If
I never could come up with any code that would work in the On Change event
of a control. (Which was my original intention)
Paul

Jeff Boyce said:
MS Access doesn't have a "Long Time" data type. It does have a format
with
that title, but formatting doesn't change the underlying data stored in a
Date/Time field.

If both those textboxes are bound to fields that are Date/Time data type
fields, you can compare them without conversion.

What happens when you try to compare them?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Hello,
On a form I have two text boxes that contain different times, the text
boxes
are formatted as Long Time.
Text114 is the system time. JETime is a time stamp.
I need to convert these two long times to doubles so I can compare the
values.
Something like:

Dim NTime As Double
Dim JET As Double


NTime = CDbl(Me.Text114.Value)
JET = CDbl(Me.JETime.Value)

If NTime > JET Then
Me.Text114.ForeColor = vbRed
End If

Or, am I completely off base using the CDbl function?
Can anyone provide help?
Thanks in advance,
Paul
 
J

Jeff Boyce

Paul

Consider posting back the solution you found.

That way, when someone else in the future is looking for a solution, they
can find yours.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Paul3rd said:
Hello Jeff,
I'm trying to compare time values. I've got the code working correctly
now.
Thanks,
Paul

Jeff Boyce said:
Paul

"Now()" is not the same as "Date()".

Now() generates a date/time value, while Date() records the date
(actually,
midnight of the date).

If you are comparing dates, you need to be working with dates
(?DateValue()).

Or am I still not understanding?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Paul3rd said:
Hello Jeff,
Sorry it took so long to get back to you,
Neither of the text boxes is bound (Text114) gets is value from
Me.Text114
=
NOW. JETime gets it's value from the expression: =[TechTime](another
time
stamp) +([FlatRate](a user input)*.042).
I have been able to use the following code in the forms timer event to
accomplish the same thing:
If DateDiff("S", Me.JETime, Me.Text114) > 10 Then
Me.Text114.ForeColor = vbRed
End If
I never could come up with any code that would work in the On Change
event
of a control. (Which was my original intention)
Paul

:

MS Access doesn't have a "Long Time" data type. It does have a format
with
that title, but formatting doesn't change the underlying data stored
in a
Date/Time field.

If both those textboxes are bound to fields that are Date/Time data
type
fields, you can compare them without conversion.

What happens when you try to compare them?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Hello,
On a form I have two text boxes that contain different times, the
text
boxes
are formatted as Long Time.
Text114 is the system time. JETime is a time stamp.
I need to convert these two long times to doubles so I can compare
the
values.
Something like:

Dim NTime As Double
Dim JET As Double


NTime = CDbl(Me.Text114.Value)
JET = CDbl(Me.JETime.Value)

If NTime > JET Then
Me.Text114.ForeColor = vbRed
End If

Or, am I completely off base using the CDbl function?
Can anyone provide help?
Thanks in advance,
Paul
 
Top