I have the following code and would like to be able to close access once the script has run. However, I'm not able to figure out the code that I need to add to close it.
Can someone help me how to accomplish this?
Thank you for collaboration.
Luis
++++++++++++++++++++++++++++++++++++++++++++++++++++
Function loadToAccess(newTap)
PathName = \\ftwgroups\jsf\jsfitcoord\FILES_FROM_INTEGRATION_DECK\Account_Mgr_Resources\IT PLANNING\2008 REVIEW FOR 2009 REQUIREMENTS\REQUIREMENTS FOR 2009.xls"
PathName = "c:\REQUIREMENTS FOR 2009.xls"
GetDbPath_Fx = "C:\"
'strDbName = GetDBPath_FX & "xpLRTactical DashBoard.mdb"
strDbName = GetDbPath_Fx & "ThisOne2007LRTactical DashBoardv1.mdb"
Dim acc As New Access.Application
Dim accAutoSec As MsoAutomationSecurity
On Error GoTo Errorhandler
'Capture current security setting
accAutoSec = acc.AutomationSecurity
'Reset the security to low temporarily to avoid the security warning
acc.AutomationSecurity = msoAutomationSecurityLow
'Open the database
acc.OpenCurrentDatabase strDbName, False, "mypassword"
strQry = "Delete * from amReqXreftlb"
With acc.CurrentDb
.Execute (strQry)
.TableDefs.Refresh
End With
acc.DoCmd.TransferSpreadsheet , acSpreadsheetTypeExcel9, TableName:="amReqXreftlb", Filename:=PathName, HasFieldNames:=True
Set acc = Nothing
acc.Quit
Exit_Sub:
Exit Function
Errorhandler:
If Err.Number <> 0 Then
MsgBox Err.Description, vbOKOnly, "Error"
Resume Exit_Sub
End If
End Function
Can someone help me how to accomplish this?
Thank you for collaboration.
Luis
++++++++++++++++++++++++++++++++++++++++++++++++++++
Function loadToAccess(newTap)
PathName = \\ftwgroups\jsf\jsfitcoord\FILES_FROM_INTEGRATION_DECK\Account_Mgr_Resources\IT PLANNING\2008 REVIEW FOR 2009 REQUIREMENTS\REQUIREMENTS FOR 2009.xls"
PathName = "c:\REQUIREMENTS FOR 2009.xls"
GetDbPath_Fx = "C:\"
'strDbName = GetDBPath_FX & "xpLRTactical DashBoard.mdb"
strDbName = GetDbPath_Fx & "ThisOne2007LRTactical DashBoardv1.mdb"
Dim acc As New Access.Application
Dim accAutoSec As MsoAutomationSecurity
On Error GoTo Errorhandler
'Capture current security setting
accAutoSec = acc.AutomationSecurity
'Reset the security to low temporarily to avoid the security warning
acc.AutomationSecurity = msoAutomationSecurityLow
'Open the database
acc.OpenCurrentDatabase strDbName, False, "mypassword"
strQry = "Delete * from amReqXreftlb"
With acc.CurrentDb
.Execute (strQry)
.TableDefs.Refresh
End With
acc.DoCmd.TransferSpreadsheet , acSpreadsheetTypeExcel9, TableName:="amReqXreftlb", Filename:=PathName, HasFieldNames:=True
Set acc = Nothing
acc.Quit
Exit_Sub:
Exit Function
Errorhandler:
If Err.Number <> 0 Then
MsgBox Err.Description, vbOKOnly, "Error"
Resume Exit_Sub
End If
End Function