Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Query - getting erratic results

Status
Not open for further replies.

SkipVought

Programmer
Dec 4, 2001
47,487
US
In a MS Access, I am running VBA. Here's the snippet that seems to be returning erratic results...
Code:
With rstPWB
...
  Do While Not .EOF
...
'Create QueryDef
    qdfPWB.SQL = "UPDATE Temp_WorkOrderEst" & _
             " SET Estimate = " & strEquation & _ 
             " WHERE Counter = " & intRecordNo & _ 
             strCondition
    Debug.Print qdfPWB.SQL
    qdfPWB.Execute
  Loop
  .Close
End With
where strEstimate is a record specific equation of numeric field elements like
Code:
(SQFTPAN*2)/(1000*MYIELDPCT*MPARTPERPAN)
It is the result of this calculation that is erratic.

???

Skip,
Skip@TheOfficeExperts.com
 
Try explicitly defining the size of each variable using the cDbl() function, etc. Access sometimes internally uses too small a variable type if each half of your calculation fits within that smaller type.

32000 * 32000 generates runtime error 6 - overflow error, as well as cdbl(32000 * 32000)

cdbl(32000) * cdbl(32000) works.

In your specific case you may need to wrap each of the individual elements.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top