Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2003
    Location
    Newbury, UK
    Posts
    1

    Unhappy Unanswered: Really Stupid Question

    Hi All,

    I am trying to launch an access 97 database (.mdb) from an Excel 97 spreadsheet, using the following code attached to a button:

    Sub CommandButton13_Click()
    Dim oAccApp As Object
    Set oAccApp = CreateObject("Access.Application")
    oAccApp.Application.Visible = True
    oAccApp.Application.OpenCurrentDatabase "<PATH HERE>\database.mdb"
    End Sub

    It's working fine except for one thing: access is loading up the database but only for a split second then instantly disappearing again. I know this is probably really obvious but can anyone help me?

    Many Thanks,
    Tom Richardson

  2. #2
    Join Date
    Jul 2003
    Location
    Plainsboro, NJ
    Posts
    11
    Your oAccApp exists only for a split second because your Function CommandButton13_Click() only exists on the Stack for a split second.

    Assuming that you want the oAccApp to persist, then you must make it a variable declared at the Module level.

    Something like:


    Option Explicit
    Dim oAccApp As Object

    Sub CommandButton13_Click()
    Set oAccApp = CreateObject("Access.Application")
    oAccApp.Application.Visible = True
    oAccApp.Application.OpenCurrentDatabase "<PATH HERE>\database.mdb"
    End Sub

    -- Mike

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •