• Open a database from my application (Access 97)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Open a database from my application (Access 97)

    Author
    Topic
    #379982

    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. igiveup

    Viewing 0 reply threads
    Author
    Replies
    • #634603

      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 Private Sub Cmd_OpenApp_Click() 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 DoCmd.SetWarnings True up to just before Exit Sub. 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 Set appAccess = Nothing, also before Exit Sub.

      • #634605

        crossfingers 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

    Viewing 0 reply threads
    Reply To: Open a database from my application (Access 97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: