R
Robe
Hi there,
I’m doing a form using two ComboBoxes the second depends on the first. The
first let me select a worker, once I select the worker then the second is
filled with some data that I get from a stored procedure. Everything is
working very well but now I need to convert the stored procedure to a
function because I need to reuse the code inside it and when I select a
worker I get this error “The parameter is invalid†in the following statement
Set objRs = objCmd.Execute.
Here is the code for the workers combobox in the form
Private Sub ComboWorker_AfterUpdate()
Dim objConn As New ADODB.Connection
Dim objCmd As New ADODB.Command
Dim objParm1 As New ADODB.Parameter
Dim objRs As New ADODB.Recordset
' Connect to the data source.
objCmd.ActiveConnection = CurrentProject.Connection
' Set CommandText to retrieve data from the stored proc
objCmd.CommandText = "spWorkerTools"
objCmd.CommandType = adCmdStoredProc
' Automatically fill in parameter info from stored procedure.
objCmd.Parameters.Refresh
' Set the param value.
objCmd(1) = ComboWorker.Value
' Execute the stored procedure
Set objRs = objCmd.Execute
' Assign the result to the ComboBox
Set ComboTools.Recordset = objRs
End Sub
The question is how I can get the table through the function instead the
stored proc?
Thanks,
I’m doing a form using two ComboBoxes the second depends on the first. The
first let me select a worker, once I select the worker then the second is
filled with some data that I get from a stored procedure. Everything is
working very well but now I need to convert the stored procedure to a
function because I need to reuse the code inside it and when I select a
worker I get this error “The parameter is invalid†in the following statement
Set objRs = objCmd.Execute.
Here is the code for the workers combobox in the form
Private Sub ComboWorker_AfterUpdate()
Dim objConn As New ADODB.Connection
Dim objCmd As New ADODB.Command
Dim objParm1 As New ADODB.Parameter
Dim objRs As New ADODB.Recordset
' Connect to the data source.
objCmd.ActiveConnection = CurrentProject.Connection
' Set CommandText to retrieve data from the stored proc
objCmd.CommandText = "spWorkerTools"
objCmd.CommandType = adCmdStoredProc
' Automatically fill in parameter info from stored procedure.
objCmd.Parameters.Refresh
' Set the param value.
objCmd(1) = ComboWorker.Value
' Execute the stored procedure
Set objRs = objCmd.Execute
' Assign the result to the ComboBox
Set ComboTools.Recordset = objRs
End Sub
The question is how I can get the table through the function instead the
stored proc?
Thanks,