在access端处理也不难,点击下载此附件:
一个窗体,一个按钮(Command0):
Private Sub Command0_Click()
Dim pName
With Application.FileDialog(3)
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "Excel 文件", "*.xls*"
' .Filters.Add "所有", "*.*"
If .Show Then
For Each pName In .SelectedItems
inputData pName
Next
End If
End With
End Sub
Function inputData(pName)
Dim Conn As New ADODB.Connection
Dim Rec As New ADODB.Recordset 'Excel表记录集
Dim Rst As New ADODB.Recordset 'acc表记录集
Dim i
Dim DJBH '单据编号
Dim DJRQ
Dim KHQC
Dim JSR
Dim SKRQ
Dim rows As Long 'Excel的行数,条件是Excel表格不能有空行.
Conn.Open "provider=Microsoft.ACE.OLEDB.12.0;extended properties='excel 8.0;imex=1';data source=" & pName
Rec.Open "select * from [销售出库单$]", Conn, adOpenStatic, adLockReadOnly
rows = Rec.RecordCount
Rec.Close
Set Rec = New ADODB.Recordset
Rec.Open "select * from [销售出库单$a2:au" & rows + 1 & "]", Conn, adOpenStatic, adLockReadOnly
Rst.Open "select * from 销售明细", CurrentProject.Connection, adOpenStatic, adLockPessimistic
For i = 1 To Rec.RecordCount
With Rst
.AddNew
If Rec("单据编号") <> "" Then
DJBH = Rec("单据编号")
DJRQ = Rec("单据日期")
KHQC = Rec("客户全称")
JSR = Rec("经手人")
SKRQ = Rec("收款日期")
End If
.Fields("单据编号") = DJBH
.Fields("单据日期") = DJRQ
.Fields("客户全称") = KHQC
.Fields("经手人") = JSR
.Fields("收款日期") = SKRQ
.Fields("商品编号") = Rec("商品编号")
.Fields("商品名称") = Rec("商品名称")
.Fields("商品规格") = Rec("商品规格")
.Fields("批号") = Rec("批号")
.Fields("数量") = Rec("数量")
.Fields("含税单价") = Rec("含税单价")
.Fields("含税金额") = Rec("含税金额")
.Update
End With
Rec.MoveNext
Next i
Rec.Close
Rst.Close
DoCmd.OpenTable "销售明细"
End Function