Hello All,
Please help I received the above error when calling a stored procedure in Access VBA. The error occurred at the rs.open line.
Please find below the code.
Regards and thanks
Private Sub RefreshValidationReason()
On Error GoTo RefreshValReason_ERR
Dim strBordVal As String
Dim intBordItemVal As Integer
strBordVal = Me.CboBordereau
intBordItemVal = Forms!frmReissuePaymentsMain!frmReissueDatasheet.Form!BordItem
'Connect to SQL Server
Dim cn As ADODB.Connection
Set cn = modDataHelper.GetAdodbConnection
'Configure the command
Dim cmd As New ADODB.Command
cmd.ActiveConnection = cn
cmd.CommandTimeout = cn.CommandTimeout
cmd.CommandText = "spRefreshReissuePaymentData '" & strBordVal & "' " ', '" & strFailValReason & "' "
cmd.CommandType = adCmdStoredProc
Dim prm As ADODB.Parameter
Set prm = cmd.CreateParameter("@BordNoVal", adVarChar, adParamInput, 50, strBordVal)
cmd.Parameters.Append prm
'Open the recordset
Dim rs As New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open cmd, , adOpenKeyset, adLockReadOnly
'Bind to Sub Form of Main Form
'Set Forms!frmReissuePaymentsMain!frmReissueDatasheet.Form.Recordset = rs
DimSet Me.frmReissueDatasheet.Form.Recordset = rs
'Bind to Sub Form of Main Form
'Set Me.Recordset = rs
'Set Forms!frmReissuePaymentsMain!frmReissueDatasheet.Form.Recordset = rs
'Set Me.txtBordNo.Value = rs.Fields(1).Value
'Close and release ADO resources
On Error Resume Next
If Not rs Is Nothing Then
rs.Close
Set rs = Nothing
End If
If Not cmd Is Nothing Then
Set cmd = Nothing
End If
If Not cn Is Nothing Then
cn.Close
Set cn = Nothing
End If
RefreshValReason_Exit:
Exit Sub
RefreshValReason_ERR:
modMessageHelper.ShowErrorMessage Err.Description, "frmReissuePaymentsMain.RefreshValReason", Err.Number
Resume RefreshValReason_Exit
End Sub
Please help I received the above error when calling a stored procedure in Access VBA. The error occurred at the rs.open line.
Please find below the code.
Regards and thanks
Private Sub RefreshValidationReason()
On Error GoTo RefreshValReason_ERR
Dim strBordVal As String
Dim intBordItemVal As Integer
strBordVal = Me.CboBordereau
intBordItemVal = Forms!frmReissuePaymentsMain!frmReissueDatasheet.Form!BordItem
'Connect to SQL Server
Dim cn As ADODB.Connection
Set cn = modDataHelper.GetAdodbConnection
'Configure the command
Dim cmd As New ADODB.Command
cmd.ActiveConnection = cn
cmd.CommandTimeout = cn.CommandTimeout
cmd.CommandText = "spRefreshReissuePaymentData '" & strBordVal & "' " ', '" & strFailValReason & "' "
cmd.CommandType = adCmdStoredProc
Dim prm As ADODB.Parameter
Set prm = cmd.CreateParameter("@BordNoVal", adVarChar, adParamInput, 50, strBordVal)
cmd.Parameters.Append prm
'Open the recordset
Dim rs As New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open cmd, , adOpenKeyset, adLockReadOnly
'Bind to Sub Form of Main Form
'Set Forms!frmReissuePaymentsMain!frmReissueDatasheet.Form.Recordset = rs
DimSet Me.frmReissueDatasheet.Form.Recordset = rs
'Bind to Sub Form of Main Form
'Set Me.Recordset = rs
'Set Forms!frmReissuePaymentsMain!frmReissueDatasheet.Form.Recordset = rs
'Set Me.txtBordNo.Value = rs.Fields(1).Value
'Close and release ADO resources
On Error Resume Next
If Not rs Is Nothing Then
rs.Close
Set rs = Nothing
End If
If Not cmd Is Nothing Then
Set cmd = Nothing
End If
If Not cn Is Nothing Then
cn.Close
Set cn = Nothing
End If
RefreshValReason_Exit:
Exit Sub
RefreshValReason_ERR:
modMessageHelper.ShowErrorMessage Err.Description, "frmReissuePaymentsMain.RefreshValReason", Err.Number
Resume RefreshValReason_Exit
End Sub