Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Mar 2002
    Location
    Edinburgh, Scotland
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Open a database from my application (Access 97)

    Hi, still learning VBA.... can anyone help with this? I have a database which gets data from dbs which are FTP'd into a holding area a few times a day. When it is opened, a query runs which pulls data from 5 databases, and makes it into one table, which in turn links to the main application. The child database then quits. I want to be able to run this process from the main application directly, but haven't done this before. Taking Access's example, my code looks like this:


    Private Sub Cmd_OpenApp_Click()
    On Error GoTo Err_Cmd_OpenApp_Click

    DoCmd.SetWarnings False

    MsgBox ("You are about to update the data in your price tables. Proceed?"), vbOKCancel

    Dim appAccess As Access.Application
    Const strConPathToDatabase = "C:My DocumentsEuropean Market"

    Dim strDB As String

    strDB = strConPathToDatabase & "EuropeanPrices.mdb"

    Set appAccess = _
    CreateObject("Access.Application.8")

    appAccess.OpenCurrentDatabase strDB

    appAccess.DoCmd.OpenForm "Frm1"


    Exit_Cmd_OpenApp_Click:
    Exit Sub

    Err_Cmd_OpenApp_Click:
    MsgBox Err.Description
    Resume Exit_Cmd_OpenApp_Click

    DoCmd.SetWarnings True

    End Sub


    The whole process works just fine, but all the same I get an error box telling me that the action will not run because access is performing another action, and to perform the action later. Can anyone tell me why this is, and what I can do to get rid of the message box, which will just confuse my users?

    many thanks. <img src=/S/igiveup.gif border=0 alt=igiveup width=31 height=23>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Open a database from my application (Access 97)

    Without more information, it's hard to say what causes the message. Perhaps you can find out by single stepping through the code: set a breakpoint on <font face="Georgia">Private Sub Cmd_OpenApp_Click()</font face=georgia> by clicking in the margin to the left of that line. If the form in the other database executes code on opening, you'll have to switch to that database.

    Note: you probably should move <font face="Georgia">DoCmd.SetWarnings True</font face=georgia> up to just before <font face="Georgia">Exit Sub</font face=georgia>. This ensures that SetWarnings will be on after the code finishes, whether an error occurred or not. Also, you need to release object memory by adding <font face="Georgia">Set appAccess = Nothing</font face=georgia>, also before <font face="Georgia">Exit Sub</font face=georgia>.

  3. #3
    Star Lounger
    Join Date
    Mar 2002
    Location
    Edinburgh, Scotland
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open a database from my application (Access 97)

    <img src=/S/crossfingers.gif border=0 alt=crossfingers width=17 height=16> I think it may be because I am trying to quit the child application from code within there, whereas I should be trying to close it from the parent. Will give this a bash, and see what happens.

    thanks as always hans

Posting Permissions

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