Unanswered: Recordset Error
I have an Access app using a SQL Server backend. I've been using ADO recordsets for several years, and have never encountered this before.
I build a string as a SQL statement:
strSql = "SELECT Sum([Crews_Fcst]*[wdays_fcst]*8) AS Hours " _
& "FROM CREWS_STRUCTURE CS INNER JOIN CREWS_WEEKS CW ON CS.WEEK_INDEX = CW.WEEK_INDEX " _
& "WHERE CS.SCEN_ID = " & SCENID & " AND CW.MNTH_YR = '" & dtmFld & "' " _
& "AND CS.PROD_LINE ='" & FrmTons!PROD_LINE & "'"
and open the recordset:
rsaCap.Open strSql, DBCNXN, adOpenForwardOnly, adLockReadOnly
I get a DIV/0 error message here if rsaCap!Hours = 0:
If rsaCap!HOURS > 0 Then
sinCap = rsaHrUsed!HOURS / rsaCap!HOURS
sinCap = -1
If the recordset opens successfully, why would testing for a >0 value
cause a DIV/0 error?
Any ideas would be greatly appreciated.
Inspiration Through Fermentation