Hello,
I am trying to create a recordset that disconnects from the external database once it has its data.
I have a DAO code which works, but to my disappointment it keeps an active lock on the external Gemini database.
I now understand that DAO can not disconncet and that I should be using a ADO connection.
I want to ensure as far as possible that there is no chance of the external database being corrupted or locked.
On this basis I think a disconnected, read only recordset is what I am after. I would greatly apprevciate being shown how to achive this and any other tips are very welcome.
The code I use currently is below.
Many thanks Mark
Option Compare Database
Dim wrkJet As Workspace
Dim dbsGemini As DAO.Database, rstGemini As DAO.Recordset
Private Sub BTN_LOAD_ACCOUNT_DblClick(Cancel As Integer)
'Create Microsoft Jet Workspace object.
Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
'Open Database object from saved Microsoft Jet database for exclusive?? use
Set dbsGemini = wrkJet.OpenDatabase("M:\Gemini.mdb", , False)
On Error Resume Next
Set rstGemini = _
dbsGemini.OpenRecordset("SELECT * " & _
"FROM " & Me.[Txttable] & " ORDER BY date desc", _
dbOpenSnapshot)
If err > 0 Then
MsgBox "Can not open Account"
Else
Set Me.Recordset = rstGemini
Me![Txtdate].ControlSource = "Date"
Me![TxtTYPE].ControlSource = "Type"
Me![TxtAmountIN].ControlSource = "Amount In"
Me![TxtAmountOUT].ControlSource = "Amount Out"
Set rstGemini = Nothing
Set dbsGemini = Nothing
End If
On Error GoTo 0
End Sub
I am trying to create a recordset that disconnects from the external database once it has its data.
I have a DAO code which works, but to my disappointment it keeps an active lock on the external Gemini database.
I now understand that DAO can not disconncet and that I should be using a ADO connection.
I want to ensure as far as possible that there is no chance of the external database being corrupted or locked.
On this basis I think a disconnected, read only recordset is what I am after. I would greatly apprevciate being shown how to achive this and any other tips are very welcome.
The code I use currently is below.
Many thanks Mark
Option Compare Database
Dim wrkJet As Workspace
Dim dbsGemini As DAO.Database, rstGemini As DAO.Recordset
Private Sub BTN_LOAD_ACCOUNT_DblClick(Cancel As Integer)
'Create Microsoft Jet Workspace object.
Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
'Open Database object from saved Microsoft Jet database for exclusive?? use
Set dbsGemini = wrkJet.OpenDatabase("M:\Gemini.mdb", , False)
On Error Resume Next
Set rstGemini = _
dbsGemini.OpenRecordset("SELECT * " & _
"FROM " & Me.[Txttable] & " ORDER BY date desc", _
dbOpenSnapshot)
If err > 0 Then
MsgBox "Can not open Account"
Else
Set Me.Recordset = rstGemini
Me![Txtdate].ControlSource = "Date"
Me![TxtTYPE].ControlSource = "Type"
Me![TxtAmountIN].ControlSource = "Amount In"
Me![TxtAmountOUT].ControlSource = "Amount Out"
Set rstGemini = Nothing
Set dbsGemini = Nothing
End If
On Error GoTo 0
End Sub