You can either use automation (heavy) or try to add a reference to DAO (or
ADO) and use it to open a database. With automation, you can do, in theory,
every thing Access can do, but it may requires a lot of extra memory. Using
DAO (or ADO), you cannot use externally defined function (like a user
defined function, something you can do using under Access). In fact, you
will be using the database a little bit like you would from VB6.
Here a small example with ADO:
Private mCnn As ADODB.Connection
Dim rst As ADODB.Recordset
' mDB is a string identifying the mdb file to connect to
mCnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0" & _
";Data Source=" & mDB & _
";Persist Security Info=False"
mCnn .Open
If mCnn.State = adStateOpen Then
Set rst = mCnn.Execute("SELECT ... ", , adCmdText)
... ' do something with that recordset
... 'and close the connection, if done.
End If
(you will still need the reference included in your app.)
Vanderghast, Access MVP