Don't suppose you know how i'd use another class from within it, such as ADODB?
I've added "Implements ADODB" but that throws an error
Ultimately, I'm trying to create a class that deals with security, in that it obtains the logged on user ID and connects to a security database to obtain any held access rights, using an ADODB recordset
ADODB is not a class, it is a whole library of classes. A recordset is a class, or a field, and so on.
To run code inside a custom class VBA offers two events, Initialize and Terminate, that you can handle. An example of code that handles the Initialize event is as follows . . .
Code:
Private Sub Class_Initialize()
MsgBox "This code runs when this class is initialized."
End Sub
If you want your class to expose an instance of a different class it is common to use a Property Get procedure, with code that might look like . . .
Code:
Private m_rst As DAO.Recordset
Property Get Recordset As DAO.Recordset
if m_rst is nothing then set m_rst = currentdb.openrecordset("SomeTable")
set Recordset = m_rst
End Property
. . . which "lazy loads" the object, so it is only ever created if a consumer requests it.