问题描述
我有一个在完整版MsAccess 2010中正常运行的数据库。但是在运行时bsp; MsAccess 2013显示错误。
I have a database that works correctly in the full version of MsAccess 2010 . but in the runtime MsAccess 2013 shows error.
............................ .................................................. .................................................. .........
.........................................................................................................................................
Dim NameTable,pathbd
Pathbd = DLookup(" [Dir_installl]"," tb_Config"," ; [Dir_install]")
NameTable =" tborcadoTemp"
Dim NameTable, pathbd
Pathbd = DLookup("[Dir_installl]", "tb_Config", "[Dir_install]")
NameTable = "tborcadoTemp"
设置objaccess = CreateObject(" Access.Application")
Set objaccess = CreateObject("Access.Application")
objaccess.NewCurrentDatabase pathbd& " tbrealizadoTemp.accdb"
objaccess.NewCurrentDatabase pathbd & "tbrealizadoTemp.accdb"
................................... .................................................. ..............................................
...................................................................................................................................
此代码创建一个accdb文件,然后将数据从一张表传输给他。
this code create a accdb file and then do the transfer of data from one sheet to him.
运行运行时不知道怎么做?
Running the runtime do not how to accomplish this?
谢谢
推荐答案
Public Sub ImportData
On Local Error GoTo LocalError
Dim AccessApplication As Access.Application
Dim DatabasePath As String
Dim FileName As String
Dim TableName As String
1 DatabasePath = Trim(DLookup("[Dir_installl]", "tb_Config", "[Dir_install]"))
2 If (Len(DatabasePath) > 1) And (Right(DatabasePath, 1) <> = "\") Then
3 DatabasePath = DatabasePath & "\"
4 End If
5 FileName = Forms![Frm_Import]![Local]
6 If (Len(Dir(FileName)) = 0) Then
7 MsgBox "File " & FileName & " does not exist."
8 Exit Sub
9 End If
10 TableName = "tborcadoTemp"
11 Set AccessApplication = CreateObject("Access.Application")
12 AccessApplication.NewCurrentDatabase DatabasePath & "tbrealizadoTemp.accdb"
13 AccessApplication.DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, TableName, FileName, True
14 AccessApplication.Quit
15 Set AccessApplication = Nothing
Exit Sub
LocalError:
MsgBox Err.Description & " at line " & Erl()
On Local Error Resume Next
AccessApplication.Quit
Set AccessApplication = Nothing
End Sub
这篇关于Msaccess 2103运行时错误CreateObject的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!