G
Guest
I am having a problem with a calculated field tring to divide by 0. Here is the code I am using
Dim db As Databas
Dim qdfAction As QueryDe
Dim sSELECT As Strin
Set db = CurrentD
sSELECT = "SELECT tblDataTable.Date, tblDataTable.Shift, tblDataTable.Dept, tblDataTable.AvailableTime, tblDataTable.Downtime, tblDataTable.StandardRate, tblDataTable.Parts, tblDataTable.DefectiveUnits, ([AvailableTime]-[downtime]/[AvailableTime]) AS availability, ([parts]*(1/([StandardRate]/(1-0.18))))/([AvailableTime]-[downtime]) AS performance, ([parts]-[DefectiveUnits])/[parts] AS Quality, [availability]*[performance]*[quality] AS oee" &
" FROM tblDataTable " &
"ORDER BY tblDataTable.Date, tblDataTable.Shift, tblDataTable.Dept
sSQL = sSELEC
Set qdfAction = db.CreateQueryDef("qrySQL", sSQL
qdfAction.Clos
DoCmd.OpenQuery "qrySQL
The problem lies in the calcuated field "Availability" because tblDataTable.Parts can be 0, not allowing 0 is not an option, nor can you update a calculated field
I not quit sure how to handle this problem. Any suggestions would be appreciated
Thank
Mar
Dim db As Databas
Dim qdfAction As QueryDe
Dim sSELECT As Strin
Set db = CurrentD
sSELECT = "SELECT tblDataTable.Date, tblDataTable.Shift, tblDataTable.Dept, tblDataTable.AvailableTime, tblDataTable.Downtime, tblDataTable.StandardRate, tblDataTable.Parts, tblDataTable.DefectiveUnits, ([AvailableTime]-[downtime]/[AvailableTime]) AS availability, ([parts]*(1/([StandardRate]/(1-0.18))))/([AvailableTime]-[downtime]) AS performance, ([parts]-[DefectiveUnits])/[parts] AS Quality, [availability]*[performance]*[quality] AS oee" &
" FROM tblDataTable " &
"ORDER BY tblDataTable.Date, tblDataTable.Shift, tblDataTable.Dept
sSQL = sSELEC
Set qdfAction = db.CreateQueryDef("qrySQL", sSQL
qdfAction.Clos
DoCmd.OpenQuery "qrySQL
The problem lies in the calcuated field "Availability" because tblDataTable.Parts can be 0, not allowing 0 is not an option, nor can you update a calculated field
I not quit sure how to handle this problem. Any suggestions would be appreciated
Thank
Mar