seanybravo
IS-IT--Management
I am using this code in a sub procedure to connect to and generate a recordset in my VB project.
Dim adoRSFields As New ADODB.Recordset
adoRSFields.CursorLocation = adUseClient
adoRSFields.Open "SELECT * FROM tblFields WHERE fldExtraFieldName IS NOT NUll", cnData
The connection string is stored in cnData however this is not filled until a database has been chosen in my project. What I cant understand is that the sub procedure is not and will not be called before cnData is set up. So why am I getting the error:
Run-time error ‘3709’:
The connection cannot be used to perform this operation. Its either closed or invalid in this context.
:when I try and run the project?
I have used a similar setup on another form and it works however it is a sub form that is not loaded until cnData is set up this may be why it works OK.
Any explanations and ways round the problem will be greatly appreciated.
TIA.
Dim adoRSFields As New ADODB.Recordset
adoRSFields.CursorLocation = adUseClient
adoRSFields.Open "SELECT * FROM tblFields WHERE fldExtraFieldName IS NOT NUll", cnData
The connection string is stored in cnData however this is not filled until a database has been chosen in my project. What I cant understand is that the sub procedure is not and will not be called before cnData is set up. So why am I getting the error:
Run-time error ‘3709’:
The connection cannot be used to perform this operation. Its either closed or invalid in this context.
:when I try and run the project?
I have used a similar setup on another form and it works however it is a sub form that is not loaded until cnData is set up this may be why it works OK.
Any explanations and ways round the problem will be greatly appreciated.
TIA.