New to VB Script here... I'm trying to populate a recordset with the results of a SQL query, then loop through that recordset and add up the values in the NetWt field to get a total net weight.
I'm getting a Type Mismatch error on the line in bold. The field NetWt in my SQL database is type Numeric(8,2). How can I resolve this error? Or is there a better way to do this?
Thanks, in advance, for your help!
strSQL = "SELECT * FROM dbo.ReceiptInfo WHERE Job = '54' ORDER BY CustomerID"
Set rstReceivingInfo = CreateObject("ADODB.Recordset")
'Open the recordset object executing the SQL statement and return records
'determine whether there are any records
If rstReceivingInfo.EOF Then
msgbox "Recordset is empty. Check your SQL string."
[b]dim TotalNetWt ' this is the variable I'm having trouble with[/b]
'if there are records then loop through them
Do While NOT rstReceivingInfo.EOF
' this is where I'm trying to force the user of a numeric variable so I can add values
[b]TotalNetWt = CDbl(TotalNetWt) + rstReceivingInfo("NetWt")[/b]
set rstReceivingInfo = nothing
set cn = nothing