Hi there,
I'm using the following code from a form's click event to pass a parameter from a combo box to a stored proc.
When running the I get a run time 3708 error, parameter not properly defined etc. The offending line is
.Parameters.Append .CreateParameter("@service1", char, adParamInput, 3, Me!SelectService)
THe code picks up the combobox value okay but can't pass it to the proc. WhenI run the proc it asks for the parameter. The paramete seems to be set in the stored proc okay. Is it a problem with the vba?
Dim adoCnn As ADODB.Connection
Dim adoCmd As ADODB.Command
Set adoCnn = New ADODB.Connection
Set adoCmd = New ADODB.Command
With adoCnn
.ConnectionString = "Driver={SQL Server};" & _
"Server=THIBERT-7;" & _
"Database=DIPartnerForecastTool;" & _
"Trusted_Connection=Yes"
If .State = 0 Then .Open
End With
With adoCmd
.ActiveConnection = adoCnn
.CommandText = "spPartner_spend_forecast"
.CommandType = adCmdStoredProc
.Parameters.Append .CreateParameter("@service1", char, adParamInput, 3, Me!SelectService)
.Execute
'Close the connection
adoCnn.Close
Thanks
I'm using the following code from a form's click event to pass a parameter from a combo box to a stored proc.
When running the I get a run time 3708 error, parameter not properly defined etc. The offending line is
.Parameters.Append .CreateParameter("@service1", char, adParamInput, 3, Me!SelectService)
THe code picks up the combobox value okay but can't pass it to the proc. WhenI run the proc it asks for the parameter. The paramete seems to be set in the stored proc okay. Is it a problem with the vba?
Dim adoCnn As ADODB.Connection
Dim adoCmd As ADODB.Command
Set adoCnn = New ADODB.Connection
Set adoCmd = New ADODB.Command
With adoCnn
.ConnectionString = "Driver={SQL Server};" & _
"Server=THIBERT-7;" & _
"Database=DIPartnerForecastTool;" & _
"Trusted_Connection=Yes"
If .State = 0 Then .Open
End With
With adoCmd
.ActiveConnection = adoCnn
.CommandText = "spPartner_spend_forecast"
.CommandType = adCmdStoredProc
.Parameters.Append .CreateParameter("@service1", char, adParamInput, 3, Me!SelectService)
.Execute
'Close the connection
adoCnn.Close
Thanks