Dirk Goldgar

G

Guest

Replying to you msg give me an error msg from server application (?).
I send this new one hoping to give you the example you requested. It was in reply to my question on how to repopulate a table with data saved in persisted recordset.
Here is the code to save the "tblpazienti" as persisted recordset

Private Sub Image6_Click()
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.Open obj.Name, CurrentProject.Connection, adOpenStatic, adLockReadOnly
rst.Save CurrentProject.Path & "\backup\pazienti", adPersistADTG
rst.Close
End Sub

Thanks,
Rocco
 
D

Dirk Goldgar

rocco said:
Replying to you msg give me an error msg from server application (?).
I send this new one hoping to give you the example you requested. It
was in reply to my question on how to repopulate a table with data
saved in persisted recordset. Here is the code to save the
"tblpazienti" as persisted recordset

Private Sub Image6_Click()
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.Open obj.Name, CurrentProject.Connection, adOpenStatic,
adLockReadOnly rst.Save CurrentProject.Path & "\backup\pazienti",
adPersistADTG rst.Close
End Sub

Thanks,
Rocco

I don't know why you had the server error, but let's move on from here.
Thanks for asking this question, because I had never done this before
and I've learned something new. Here's how you might restore table
tblPazienti from the persistent recordset you saved:

Dim rstSaved As ADODB.Recordset
Dim rstRestore As ADODB.Recordset
Dim intFX As Integer

Set rstSaved = New ADODB.Recordset
rstSaved.Open _
CurrentProject.Path & "\backup\pazienti", , , , adCmdFile

Set rstRestore = New ADODB.Recordset
rstRestore.Open "tblPazienti", _
CurrentProject.Connection, adOpenDynamic, adLockOptimistic

With rstSaved
Do Until .EOF
rstRestore.AddNew
For intFX = 0 To .Fields.Count - 1
rstRestore.Fields(intFX).Value = .Fields(intFX).Value
Next
rstRestore.Update
.MoveNext
Loop
.Close
rstRestore.Close
End With

Set rstSaved = Nothing
Set rstRestore = Nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top