G
Guest
I am trying to transfer control to a second Access database and close down
the current one. The code below works fine in several other databases but
does not in the current one I am working on. It doesn't open up the new
database. However it does close down the current one. Is there a setting some
place that I am missing that prevents Access from opening up a new database?
Function cmd_PivotReport()
'*****************************************************************************************
'* Special pivot report created for Gowri
*
'*****************************************************************************************
On Error GoTo HandleErr
Const strProcName As String = "Switchboard - cmd_PivotReport"
Dim dbMyDb As Access.Application
Dim strPath As String
Dim strFile As String
strPath = "K:\SUPPLY\Finance Cust Serv\Claims\CBSply\CLMFront\"
strFile = "CBALISAPAIDS.mdb"
With Application.FileSearch
.LookIn = strPath
.FileName = strFile
If .Execute Then
' Open new database
Set dbMyDb = New Access.Application
dbMyDb.OpenCurrentDatabase (strPath & strFile)
' Close currently open database.
Application.Quit
Else
MsgBox "The Access Database " & strFile & " was not found in the " _
& strPath & " directory. The program has been aborted. Please make
sure " _
& "the database exists in that specific directory and then try again."
Exit Function
End If
End With
ExitHere:
Exit Function
HandleErr:
Select Case Err.Number
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical,
strProcName
End Select
GoTo ExitHere
End Function
the current one. The code below works fine in several other databases but
does not in the current one I am working on. It doesn't open up the new
database. However it does close down the current one. Is there a setting some
place that I am missing that prevents Access from opening up a new database?
Function cmd_PivotReport()
'*****************************************************************************************
'* Special pivot report created for Gowri
*
'*****************************************************************************************
On Error GoTo HandleErr
Const strProcName As String = "Switchboard - cmd_PivotReport"
Dim dbMyDb As Access.Application
Dim strPath As String
Dim strFile As String
strPath = "K:\SUPPLY\Finance Cust Serv\Claims\CBSply\CLMFront\"
strFile = "CBALISAPAIDS.mdb"
With Application.FileSearch
.LookIn = strPath
.FileName = strFile
If .Execute Then
' Open new database
Set dbMyDb = New Access.Application
dbMyDb.OpenCurrentDatabase (strPath & strFile)
' Close currently open database.
Application.Quit
Else
MsgBox "The Access Database " & strFile & " was not found in the " _
& strPath & " directory. The program has been aborted. Please make
sure " _
& "the database exists in that specific directory and then try again."
Exit Function
End If
End With
ExitHere:
Exit Function
HandleErr:
Select Case Err.Number
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical,
strProcName
End Select
GoTo ExitHere
End Function