scotts27
asked on
Record set always available
I would like to create a record set and have it available throughout a module. I currently have the following lines:
rs_VendorData.CursorLocati on = adUseClient
rs_VendorData.Open VendorDataSQLquery, ConnectionString, adOpenDynamic
My query and connectstring are defined at the top of my code on formload.
This code currently resides in the function I am calling so it is run every time (some 2000 times) when I place it in the calling procedure it is available the first time I call the function, once the function returns, the watchwindow will show all the elements in my recordset as out of context.
How does one set a recordset tyo be available for the "life" of a module.
Thanks.
rs_VendorData.CursorLocati
rs_VendorData.Open VendorDataSQLquery, ConnectionString, adOpenDynamic
My query and connectstring are defined at the top of my code on formload.
This code currently resides in the function I am calling so it is run every time (some 2000 times) when I place it in the calling procedure it is available the first time I call the function, once the function returns, the watchwindow will show all the elements in my recordset as out of context.
How does one set a recordset tyo be available for the "life" of a module.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try setting the value of Procedure to (All Procedures) in the Context frame on the Add Watch window. Additionally the recordset object should be declared at the top of the form with ConnectionString and query object.
Easiest way is to move it up to the module level. Declare a .BAS module and put the initialization and variable definitions there. Set the project properties to start in Sub Main() and open the recordset in that routine. Everyone, everywhere will have access to the data set.
Be sure to close the database connection down at exit time. You need a common exit handler so that the user clicking on [X] on any form will either be ignored or initiate an orderly shutdown.
Typically I have a Public Sub in the module called Die. It codes up as:
Public Sub Die()
'
Dim Frm as Form
'
On Error Resume Next
db.close
'
for each frm in forms
unload frm
set frm = nothing
next frm
'
end
'
end sub
M
Be sure to close the database connection down at exit time. You need a common exit handler so that the user clicking on [X] on any form will either be ignored or initiate an orderly shutdown.
Typically I have a Public Sub in the module called Die. It codes up as:
Public Sub Die()
'
Dim Frm as Form
'
On Error Resume Next
db.close
'
for each frm in forms
unload frm
set frm = nothing
next frm
'
end
'
end sub
M