I have a Function which might return a Null Value. As you can see I am using vbNull which is failing "Invalid use of Null".
How should I test for this?
Private Function CreInvData(ByVal sStoredProcName As String) As LongDim oCmd As New ADODB.CommandDim oParam As ADODB.ParameterSet oCmd.ActiveConnection = invConnoCmd.CommandText = sStoredProcNameoCmd.CommandType = adCmdStoredProcoCmd.Parameters.Append oCmd.CreateParameter("clCode", adVarChar, adParamInput, 4, sClCode)oCmd.Parameters.Append oCmd.CreateParameter("chgRate", adInteger, adParamInput, , i)oCmd.Parameters.Append oCmd.CreateParameter("clStRate", adCurrency, adParamInput, , clStRate)oCmd.Parameters.Append oCmd.CreateParameter("W", adVarChar, adParamInput, 1, W)oCmd.Parameters.Append oCmd.CreateParameter("Total", adCurrency, adParamReturnValue)oCmd.ExecuteIf oCmd.Parameters("Total") = vbNull Then total = 0Else total = oCmd.Parameters("Total")End If
I am naming "Total" when creating the Return Value parameter:
oCmd.Parameters.Append oCmd.CreateParameter("Total", adCurrency, adParamReturnValue)
The value coming back is Null (or a Currency Value).
As to your suggestion I am using vb6 and I don't think System.dbNull.Value is vb6 syntax. I would have thought vbNull would work but it doesn't for some reason. Is it perhaps the adCurrency datatype I am using?
Thanks for your help.
Something like:
Open in new window
Total gets 0 if it is null.
The way you are using it, you are treating NULL as a value and it is not.