|
|
Программное создание базы данных (временной) - CreateTempDb (DAO)
Public Sub CreateTempDb(Optional TempFileName As String = "TempDB.accdb")
Dim TempDBPath As String
Dim db As DAO.Database
Dim strDBaseLink As String
Dim l As Long
Dim sTableNameTempalete$, sTableNameLocal$
On Error GoTo CreateTempDb_Err
TempDBPath = CurrentProject.Path & "\" & TempFileName
If Dir(TempDBPath) <> "" Then
Kill TempDBPath
DoEvents
Err.Clear
End If
Set db = DBEngine.CreateDatabase(TempDBPath, dbLangCyrillic, dbVersion120)
strDBaseLink = ";DATABASE=" & TempDBPath
sTableNameTempalete = "00tp_TabelFromExcel"
sTableNameLocal = Mid(sTableNameTempalete, 3)
DoCmd.CopyObject TempDBPath, sTableNameLocal, acTable, sTableNameTempalete
l = esConnectToTable(strDBaseLink, sTableNameLocal)
sTableNameTempalete = "00tp_AIR_Report"
sTableNameLocal = Mid(sTableNameTempalete, 3)
DoCmd.CopyObject TempDBPath, sTableNameLocal, acTable, sTableNameTempalete
l = esConnectToTable(strDBaseLink, sTableNameLocal)
CurrentDb.TableDefs.Refresh
Application.RefreshDatabaseWindow
DoEvents
CreateTempDb_Bye:
On Error Resume Next
db.Close
Set db = Nothing
Err.Clear
Exit Sub
CreateTempDb_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description & vbCrLf & _
"in procedure CreateTempDb", vbCritical, "Error!"
Resume CreateTempDb_Bye
End Sub
|
|