Private Sub Command21_Click()
If Me.xls_path = "" Or IsNull(Me.xls_path) Then
MsgBox "请按…按钮选择要导入的Excel数据表!", vbExclamation, "提示" '如果文件路径为空时提示
Exit Sub
End If
Dim sSQL As String
Dim nRowAffected As Long
sSQL = "insert into 人员表" _
& " select * from [222$] IN '' [Excel 8.0;Database=" & Me.xls_path.Value & "] " _
& " where 编号 not in (select 编号 from 人员表)"
CurrentProject.Connection.Execute sSQL, nRowAffected
If nRowAffected > 0 Then
msbgox "[" & nRowAffected & "] Row inserted from excel file " & Me.xls_path.Value
End If
MsgBox "数据导入成功!", vbInformation, "导入成功" '提示导入成功
End Sub