一直以来,ACCESS 数据 库 中的申报 数据 在分公司与总公司之间 传递 ,用EXCEL或DBASE、TXT甚至ACCESS等格式,我总觉得不太理想。最近看了一本书,不经意间发现了一个 方法 ,使用ACCESS 数据 库 生成申报 数据 与读入 数据 似乎简单了不少,特拿出来与大家
一直以来,ACCESS
数据库中的申报
数据在分公司与总公司之间
传递,用EXCEL或DBASE、TXT甚至ACCESS等格式,我总觉得不太理想。最近看了一本书,不经意间发现了一个
方法,使用ACCESS
数据库生成申报
数据与读入
数据似乎简单了不少,特拿出来与大家分享。同时,也希望能得到更多的指点。
附上示例:
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
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn