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
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