Newbie(ish) Question about class modules
I am writing a fairly Maths-intensive application for an Engineering firm and am trying to based it on a database. I am using class modules to tie in with each table in the database and use the following code to connect (copied from COM tutorial 2):
Code:
Private Sub Class_Initialize()
Set rs = New Recordset
rs.ActiveConnection = "Provider=Microsoft." & _
"Jet.OLEDB.4.0;Data Source=" & App.Path & _
"\CentralDB.mdb;" & "Persist Security Info=False"
rs.Open "select * from JointTypes", , adOpenKeyset, adLockOptimistic
End Sub
Private Sub Class_Terminate()
rs.Close
Set rs = Nothing
End Sub
I am trying to keep the number of global variables as low as possible. If the class module is called Joint then for example I will put this code locally and pass parameters between subroutines:
Code:
Dim uJoint as Joint
Set uJoint= New Joint
The program works very well, but it is too slow as it is having to connect to the database all the time and I need a way of keeping the CurrentRecord the same when switching between different subs, modules, forms etc as the program is quite complicated.
This may seem a really elementary question but remember I am totally new at this (since yesterday when I read the database and COM tutorials)
Thanks