PMFJI,
When creating recordsets, you should always check to see if records are returned.
Code:
Public Function fnCalcEhrs() As Variant
Dim r As DAO.Recordset
Dim sSQL As String
'Default return value
fnCalcEhrs = 0
' open inline SQL (or saved query)
sSQL = " SELECT EWOID,[Type], SumofWorkers, SumofDuration, [Hours] "
sSQL = sSQL & " FROM qrySumAWREquipHours "
sSQL = sSQL & " WHERE EWOID = " & Forms!frmAWR!EWOID
Debug.Print sSQL
Set r = CurrentDb.OpenRecordset(sSQL)
If Not r.BOF And Not r.EOF Then
fnCalcEhrs = r!Hours
End If
r.Close
Set r = Nothing
End Function
Here is an alternative to check for records
Code:
If r.BOF And r.EOF Then
' no records - do nothing
Else
fnCalcEhrs = r!Hours
End If
*************************************************
Be aware that "TYPE" is a reserved word and should NOT be used for object names.
tblObjectResources.Type
EWOID,[Type]
************************************************** ***********
BTW, when you want to paste code in the reply, click the hash (#) mark, then paste the code between the tags.