opening new databases with button using VBA

eggwater

life as a rehearsal
Local time
Today, 17:51
Joined
Aug 14, 2003
Messages
69
I thought this'd be simple but I can't figure it out.

For reasons of laziness and the need for a quick fix I've had to make a copy of my database - FE and BE - so that all records for this year are held in one and last year in the other - (extraneous info: My users need access to this year's and last year's records but they can't be stored in the same database at the moment because it would mean that I would have to recode a load of VBA to filter off last years records and make new forms etc etc (i.e. a pain in the arse) and I'm off on holiday in a few days).

so my question is: how can I create a switchboard with two buttons that open each database then close the switchboard?

I tried some VBA with path names but it didn't work cos I haven't coded for about 6 months and I've gone rusty can anyone help - this must be super simple.

cheers in advance
 
sorry I'm not sure what's going on with that code anychance you could explain it a bit to me?

I was using this:

Dim stDocName As String

stDocName = "N:\NewDatabaseTest\Yr2k2test2004.mdb"
DoCmd.OpenCurrentDatabase stDocName
 
Put this part in a module

Code:
Public appAccess As Access.Application

Public Sub OpenADatabase(ByVal strPath As String)
    
    Set appAccess = CreateObject("Access.Application")
     
    With appAccess
        .OpenCurrentDatabase strPath
        .Visible = True
    End With

End Sub

And, on the click of your button you put:

Code:
stDocName = "N:\NewDatabaseTest\Yr2k2test2004.mdb"
Call OpenADatabase(stDocName)
 
hey that works and I have no idea why?!

cheers anyhow

one more thing - can I do a command that closes the database with the switchboard:

something like DoCmd.CloseCurrentDatabase ??

god I wish this programming gubbins would stay inside my brain!

cheers
 
and that goes where?

will that close access before the new application opens?

sorry to be a pain
 
ei!

Ei, Guys! I also have a proble about OpenCurrentDatabase and I just got what I need. Thanks a lot! :)
 
Thanks SJ used it to open a database while shutting down another

EG.
Dim appAccess As Access.Application
Set appAccess = CreateObject("Access.Application")

With appAccess
.OpenCurrentDatabase ("d:mdb\autowvc2.mdb")
.Visible = False
End With
DoCmd.Quit
End Function
 

Users who are viewing this thread

Back
Top Bottom