我有一个包含字段
的访问表ID
Field1
Field2
Field3
我还有一个带标题的单词表
ID | Field1 | Field2 | Field3
如何从表格中自动将表格中的所有数据导入评估数据库?
答案 0 :(得分:1)
自动导入并不容易,但您可以通过编程方式进行。
从Access,您可以执行以下操作:
dim base as string: base = "INSERT INTO tblname (ID, Field1, Field2, Field3) VALUES ("
dim sql as string
dim ii as long
dim jj as long
dim wrd as object
dim wrdDoc as object
'
docmd.setwarnings false
set wrd = createObject("Word.Application")
wrd.visible = false
set wrdDoc = wrd.Documents.Add("name of word document containing table")
with wrdDoc.Tables(1) 'assuming first table in document
for ii = ? to .Rows.Count 'if the table has column headings, ? = 2, else 1
sql = base
for jj = 1 to 4 '4 = count of columns
sql = sql & iif(jj = 1, "", ",") & CStr(.Cell(ii, jj))
next jj
sql = sql & ")"
docmd.runsql sql
next ii
end with
docmd.setwarnings true
wrd.Quit
set wrddoc = nothing
set wrd = nothing