scoop10000
New member
- Local time
- Today, 02:45
- Joined
- Aug 19, 2004
- Messages
- 9
Could someone advise me on the best time to make a connection through to a database
I'm relatively new to VBA but started making connections through to the database successfully a few months ago. I now want to improve my understanding of the correct methodology.
I find now that I am adding a lot of connections strings within various actions on the same Access form. I presume I could make one connection on the onLoad event and set it to nothing on the close event. Would this be an inaccurate assumption.
For example the code below is the connection I use. Currently this is coded several times on the same form which i feel is inefficient
Any comments would be appreciated
I'm relatively new to VBA but started making connections through to the database successfully a few months ago. I now want to improve my understanding of the correct methodology.
I find now that I am adding a lot of connections strings within various actions on the same Access form. I presume I could make one connection on the onLoad event and set it to nothing on the close event. Would this be an inaccurate assumption.
For example the code below is the connection I use. Currently this is coded several times on the same form which i feel is inefficient
Code:
Dim rstProducts As New ADODB.Recordset
Set curdb = currentdb
Set CurConn = New ADODB.Connection
With CurConn
.Provider = "Microsoft.jet.oledb.4.0"
.ConnectionString = "data source=" & curdb.Name
.Open
End With
Set rstProducts = New ADODB.Recordset
Any comments would be appreciated
Last edited by a moderator: