Trying to transfer control to a second Access database

  • Thread starter Thread starter Guest
  • Start date Start date
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 following seems to work for me. The only thing I'm doing here that you
didn't do in your code is to set obj.Visible = True.

Public Sub NewAccApp()

Dim obj As Access.Application
Set obj = New Access.Application
obj.OpenCurrentDatabase CurrentProject.Path & "\db1.mdb"
obj.Visible = True
Application.Quit

End Sub
--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
I have a somewhat related question. I am using the same
command as below "Application.FileSearch". The db is on
a server - everything works fine from most locations,
however there are a few "terminals" (there are
others "terminals" that work fine) where an
error: "method object failed" is reported. The network
manager seems to think this is due to some security
controls and is checking that. I wanted to see if there
are any other possibilities in case that leads nowhere.

THANKS!
 
Someone posted a reply here, but I'm not seeing it now.
I appreciate your response, but it didn't seem to work as
written. It was "for each"... anyway, looking for
another possibility here, all the changes which need to
be "accepted" are on one page. Anyone know of a way to
select the first page, or section, and approve all on
there?

I've played around, but no luck yet.

THANKS again for any and all help! References, snip-its -
whatever!
 
Back
Top