Switchboard?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How would I use the Switchboard to open an archived copy of the database, say
I want to archive the 2006 records in another database but have them
available by using the switchboard with the click of a button. I don't see
an OpenDatabase or Open Access Command I can add to the Command button? I am
not good with Visual Basic any help would be appreciated.
 
Hi Ann

I copied this from an answer I gave a while ago. You can use it to open
quite a few databases from the same switchboard.


______________________________________

The basic call shell on the OnClick of a button would look something like
this


Private Sub ButtonName_Click()
Call Shell("""C:\Documents and Settings\My Documents\DataBase1.mdb""", 1)
End Sub


Or you could create an unbound combo - or bind it so you can store the DB
table names and paths in a table. Then on the AfterUpdate event you could
use something like this


Private Sub ComboName_AfterUpdate()
If Me.ComboName = Database1 Then
Call Shell("""C:\Documents and Settings\My Documents\DataBase1.mdb""", 1)
End If
If Me.ComboName = Database2 Then
Call Shell("""C:\Documents and Settings\My Documents\DataBase2.mdb""", 1)
End If
If Me.ComboName = Database3 Then
Call Shell("""C:\Documents and Settings\My Documents\DataBase3.mdb""", 1)
End If
End Sub


Or you could use an option group - if case 1 then open DB1 if case 2 open
DB2, etc.


There are quite a few methods it just depends on what you feel is best for
your app.


Don't forget you can also use call shell to run a macro when you open a
specific DB (to open a form or whatever).

I assume your DB's are at
C:\Documents and Settings\My Documents\

If not the change this line in the code to the correct path.
Tip - To find the path
Click start.
Select Run
Select browse
Navigate to your DB (you will need to select show all files)
Click the DB (but don't open)
Cut the path from the run box and paste it into your code

Hope this helps
 
Back
Top