All along, the Access database in the reporting data between the branch and the head office, in Excel or dBASE, TXT and even access formats, I always feel less than ideal. Recently read a book, inadvertently found a way to use an Access database to generate the declaration data and read the data seems a lot simpler, special take out to share with you. At the same time, also hope to get more guidance.
Attached example:
Sub Mwrite ()
On Error GoTo Thiserr
Dim rs as New ADODB. Recordset
Rs. Open "DLMD", CurrentProject.Connection, adOpenDynamic, adLockOptimistic, actable
Rs. Save "A:\DLMD.ADTG", ADPERSISTADTG
Rs. Close
Set rs = Nothing
Thisexit:
Exit Sub
Thiserr:
MsgBox Err.Description
Resume Thisexit
End Sub
Sub Mread ()
On Error GoTo Merr
Dim I as Integer
Dim Rsde as New ADODB. Recordset
Dim Rsso as New ADODB. Recordset
Rsso.open "A:\DLMD.ADTG", "Provider=mspersist"
Rsde.open "DLMD", CurrentProject.Connection, adOpenKeyset, adLockOptimistic, actable
Do Until rsso.eof
Rsde.addnew
For i = 0 to Rsso.fields.count-1
Rsde.fields (i) = Rsso.fields (Rsde.fields (i). Name)
Next I
Rsde.update
Rsso.movenext
Loop
Rsso.close
Rsde.close
Set Rsso = Nothing
Set Rsde = Nothing
Mexit:
Exit Sub
Merr:
MsgBox Err.Description
Resume Mexit
End Sub