error user defined type not defined

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have this function in global code that I am calling from a query. I am
getting an error message User defined type not defined. I am a VFP
programmer, new to access. I had originally forgotten to add the "as long"
at the end of the function, but even after I did, I'm still getting the same
error.

Function CalcHours() As Long
Dim TimeScheduled As Long
Dim Multiplier As intger

TimeScheduled = [Schedule.SCH Start Time] - [Schedule.SCH End Time]
Multiplier = 0
If [Schedule.SCH Sunday] = yes Then Multiplier = Multiplier + 1
If [Schedule.SCH Monday] = yes Then Multiplier = Multiplier + 1
If [Schedule.SCH Tuesday] = yes Then Multiplier = Multiplier + 1
If [Schedule.SCH Wednesday] = yes Then Multiplier = Multiplier + 1
If [Schedule.SCH Thursday] = yes Then Multiplier = Multiplier + 1
If [Schedule.SCH Friday] = yes Then Multiplier = Multiplier + 1
If [Schedule.SCH Saturday] = yes Then Multiplier = Multiplier + 1

If Multiplier > 0 Then
CalcHours = TimeScheduled * Multiplier
Else
CalcHours = TimeScheduled
End If
End Function
 
Thanks, that helped, but I'm still having a problem.

That didn't work, but changing function and all the dims to long worked.
However, now I'm getting an error message at the line
TimeScheduled = [Schedule.SCH Start Time] - [Schedule.SCH End Time]
the error is external name not defined. I'm calling this from a query.
Schedule is the name of a table, [sch start time] and [sch end time] are the
field names.

Mike Revis said:
Try Integer

terry said:
I have this function in global code that I am calling from a query. I am
getting an error message User defined type not defined. I am a VFP
programmer, new to access. I had originally forgotten to add the "as long"
at the end of the function, but even after I did, I'm still getting the same
error.

Function CalcHours() As Long
Dim TimeScheduled As Long
Dim Multiplier As intger

TimeScheduled = [Schedule.SCH Start Time] - [Schedule.SCH End Time]
Multiplier = 0
If [Schedule.SCH Sunday] = yes Then Multiplier = Multiplier + 1
If [Schedule.SCH Monday] = yes Then Multiplier = Multiplier + 1
If [Schedule.SCH Tuesday] = yes Then Multiplier = Multiplier + 1
If [Schedule.SCH Wednesday] = yes Then Multiplier = Multiplier + 1
If [Schedule.SCH Thursday] = yes Then Multiplier = Multiplier + 1
If [Schedule.SCH Friday] = yes Then Multiplier = Multiplier + 1
If [Schedule.SCH Saturday] = yes Then Multiplier = Multiplier + 1

If Multiplier > 0 Then
CalcHours = TimeScheduled * Multiplier
Else
CalcHours = TimeScheduled
End If
End Function
 
I actually answered that one myself. I added query! in front of the name and
change the table to the query name. But I'm still having problems...

How do I calculate the hours worked from start time (med. time) to end time
(med. time) I'm getting a decimal number not even close to the number of
hours. ex
start time 8am
end time 11am
want result of 2
am getting result of 0.125 How do I convert this to 2?

terry said:
Thanks, that helped, but I'm still having a problem.

That didn't work, but changing function and all the dims to long worked.
However, now I'm getting an error message at the line
TimeScheduled = [Schedule.SCH Start Time] - [Schedule.SCH End Time]
the error is external name not defined. I'm calling this from a query.
Schedule is the name of a table, [sch start time] and [sch end time] are the
field names.

Mike Revis said:
Try Integer

terry said:
I have this function in global code that I am calling from a query. I am
getting an error message User defined type not defined. I am a VFP
programmer, new to access. I had originally forgotten to add the "as long"
at the end of the function, but even after I did, I'm still getting the same
error.

Function CalcHours() As Long
Dim TimeScheduled As Long
Dim Multiplier As intger

TimeScheduled = [Schedule.SCH Start Time] - [Schedule.SCH End Time]
Multiplier = 0
If [Schedule.SCH Sunday] = yes Then Multiplier = Multiplier + 1
If [Schedule.SCH Monday] = yes Then Multiplier = Multiplier + 1
If [Schedule.SCH Tuesday] = yes Then Multiplier = Multiplier + 1
If [Schedule.SCH Wednesday] = yes Then Multiplier = Multiplier + 1
If [Schedule.SCH Thursday] = yes Then Multiplier = Multiplier + 1
If [Schedule.SCH Friday] = yes Then Multiplier = Multiplier + 1
If [Schedule.SCH Saturday] = yes Then Multiplier = Multiplier + 1

If Multiplier > 0 Then
CalcHours = TimeScheduled * Multiplier
Else
CalcHours = TimeScheduled
End If
End Function
 
Back
Top