The error is "Operation is not allowed when the object is closed.
This error occures ONLY when I run code right after I opened my VB6 project. The code runs just fine when I repeat runs during the same session.... I have no clue...
This is the code:
If anybody could give me an advice, I would highly appretiate it.
:0)
This error occures ONLY when I run code right after I opened my VB6 project. The code runs just fine when I repeat runs during the same session.... I have no clue...
This is the code:
Code:
Dim objRcrdstFromExcel As New ADODB.Recordset
Dim objExcelConn As New ADODB.Connection
Dim objCmdExcel As New ADODB.Command
Dim objCmdInsertIntoAccess As New ADODB.Command
Dim strFieldsValues As String
Dim strFieldsNames As String
Dim strSQL As String
Dim strClause As String
' *****************************************************************************
With objExcelConn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source= " & gobjBufferWBook.FullName & ";Extended Properties=Excel 8.0;"
.Open
End With
strClause = GetBusItemsClause
' *****************************************************************************
Set objCmdExcel.ActiveConnection = objExcelConn
objCmdExcel.CommandType = adCmdText
objCmdExcel.CommandText = "SELECT * FROM [" & SHEET_REQUESTS & "]" & vbCrLf & "WHERE " & strClause
objRcrdstFromExcel.CursorLocation = adUseClient
objRcrdstFromExcel.CursorType = adOpenStatic
objRcrdstFromExcel.LockType = adLockReadOnly
objRcrdstFromExcel.Open objCmdExcel ' <<<<<<<<<< This is the line that gives the error...
......
:0)