ADO Connection Question

hascons

Registered User.
Local time
Today, 15:11
Joined
Apr 20, 2009
Messages
58
Hello,

I'm experimenting with splitting my access database and possibly using Vb.net or other as a front end. I have begun updating my forms to unbound forms and populating,adding,deleting etc.. with them using ADO. This has gone well and all forms are working properly.

My question is that I use many forms and reports to enter or navigate to specific records. In each form code module I set a connection do whatever needs to be done and then close Connection. Is there a way to do this outside the form module so this can be done for every form or report.I would think i could simplify this somewhat such as:

Private Sub Form_Open()
EstablishConnection.Open("Employees")
End Sub

Do I need to do this through a class Module or Standard Module? (I've never reallyused a class Module)

I've attached the code for 1 of the forms.

Dim rstEmployees As ADODB.Recordset
Dim cnn As ADODB.Connection

Private Sub Form_Close()
Set rstEmployees = Nothing
End Sub

Private Sub Form_Open(Cancel As Integer)

Set rstEmployees = New ADODB.Recordset
rstEmployees.CursorType = adOpenKeyset
rstEmployees.LockType = adLockPessimistic
rstEmployees.Open "[Employees]", CurrentProject.Connection, , , adCmdTable

End Sub
 
a couple things you might consider here. First of all, ADO is not necessary if you're working with the current db. Secondly, consider a universal function that take in a couple of arguments, say a table/form name and something else.

then on your forms, on the event of your choice you can enter =function("thisformname", "other")

 
The net 2.0

I found a class Module that i was able to incorporate into my project. It does help but I do agree that much of what i've done seems to done easier with DAO.

I was experimenting with splitting my database and thought that ADO was required to communicate between the 2 databases. I've found however that DAO works fine even when splitting the database.
 
thought that ADO was required to communicate between the 2 databases. I've found however that DAO works fine even when splitting the database.
nothing other than the linked table manager is needed to manage a FE/BE connection between two Access files.

Remote BE's though, will require connection strings or DSNs.
 

Users who are viewing this thread

Back
Top Bottom