1.在導入excel數據時,盡量改用ado的方式打開,速度和效率會更快 Set mConn = New ADODB.Connection With mConn .CursorLocation = adUseClient .Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mPath & "\yourexecl.xls;Extended Properties=""Excel 8.0;""" End With Set mRsRead = New ADODB.Recordset mRsRead.CursorLocation = adUseClient
所以,你的问题可以变通一下:先导入职工记录数据,然后编程为Access的每一条记录生成一个编号(根据你的公式)。
//导入临时表 你的是什么条件哪?
Set mConn = New ADODB.Connection
With mConn
.CursorLocation = adUseClient
.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mPath & "\yourexecl.xls;Extended Properties=""Excel 8.0;"""
End With
Set mRsRead = New ADODB.Recordset
mRsRead.CursorLocation = adUseClient
mRsRead.Open "select F1,F2,F3,F4 from [yourexeclsheet$] ", mConn, adOpenStatic, adLockOptimistic, adCmdText
2.你也可以從access中導入功能直接做導入,如果你的excel有固定格式的話