Calling Function - Type mismatch

G

George

My problem I believe is with my Duration field which is
text and I have to convert it to integer to test and
calculate it. In another language I would redefine the
text field as numeric and use the numeric field. How do I
do that with Access/VBA? Here is my code.

In my report I have..... = ConvertDur[(Duration)] ...the
Duration is my table field and is Text. There is numeric
data in the text field which I need to convert. How do I
move Text into a Integer so I won't get the type mismatch?

In my function I have ....
Option Explicit
Public Function ConvertDur(Duration As Text) As String
Dim calDur As Integer
Dim calHr As Integer
Dim calMin As Integer
Dim calSec As Integer
Dim calRem As Integer

If Duration <> " " Then
calDur = Duration '??? I think this is my problem
'??? How do to correct this?
Else
Exit Function
End If

If calDur < 60 Then
ConvDur = ((0) & ":" & calDur)
Else
If calDur >= 60 And calDur < 3600 Then
calMin = (calDur \ 60)
If (calDur - calMin = Not 0) Then
calSec = (calDur - calMin)
End If
ConvDur = (calHr & ":" & calMin & ":" & calSec)
End If
Else
If calDur > 3600 Then
calHr = (calDur \ 3600)
calRem = (calDur - 3600)
calMin = (calRem \ 60)
calSec = (calRem - (calMin * 60))
ConvDur = (calHr & ":" & calMin & ":" & calSec)
End If
End If
End Function
...............
Is there another way to convert this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top