ironwarrior
New member
- Local time
- Today, 11:15
- Joined
- Apr 23, 2015
- Messages
- 6
Hey all,
I'm having an issue getting a return value from a stored procedure that I'm calling from VBA. I've tried looking around for a solution, but can't seem to get it to work. This is what I have at the moment:
The problem I am having is this error:
Error: 424
Description: Object Required
The line of code it errors on is:
And the value of ParamReturn is always Null after it hits the line before it.
So it seems like it's not really creating the parameter variable SQL Server needs to run it? What am I doing wrong here?
Thanks!
I'm having an issue getting a return value from a stored procedure that I'm calling from VBA. I've tried looking around for a solution, but can't seem to get it to work. This is what I have at the moment:
Code:
Dim strDate As String
Dim strWOStatus As String
Dim CurrentConnection As ADODB.Connection
Dim adoCMD As ADODB.Command
Dim adoRS As ADODB.Recordset
Dim ParamReturn As ADODB.Parameter
Dim PartsUsedMTD As Integer
'set default connection/values
Set CurrentConnection = AdoConnection()
'set AssetID value
strAsset = lngAssetID
' Parts Used on Work Orders
strDate = GetMTD(strDate)
Set adoCMD = New ADODB.Command
With adoCMD
.ActiveConnection = CurrentConnection
.CommandText = "spPartsUsedMTD"
.CommandType = adCmdStoredProc
.Parameters.Refresh
.Parameters("@Asset").Value = strAsset
.Parameters("@PartDate").Value = strDate
Set ParamReturn = .CreateParameter("@varPartsUsedMTD", adInteger, adParamReturnValue)
Set .Parameters("@PartsUSedMTD").Value = ParamReturn
.Execute , , adExecuteNoRecords
PartsUsedMTD = .Parameters("@varPartsUsedMTD")
End With
Me.txtPartsUsedMTD = PartsUsedMTD
The problem I am having is this error:
Error: 424
Description: Object Required
The line of code it errors on is:
Code:
Set .Parameters("@PartsUSedMTD").Value = ParamReturn
And the value of ParamReturn is always Null after it hits the line before it.
So it seems like it's not really creating the parameter variable SQL Server needs to run it? What am I doing wrong here?
Thanks!