Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

open an existing database from VB6

Hi,
I'll try to open an existing database from VB6. the database opens but won't show.
My general idee was to open the database from Vb and then by opening the base the autoexec macro started.
I see that the database is open on the .ldb extencion, but nothing seems to start.
Please give me a helping hand
Cheyenne

Comments

  • dokken2dokken2 Member Posts: 532
    : Hi,
    : I'll try to open an existing database from VB6. the database opens
    : but won't show.
    : My general idee was to open the database from Vb and then by opening
    : the base the autoexec macro started.
    : I see that the database is open on the .ldb extencion, but nothing
    : seems to start.
    : Please give me a helping hand
    : Cheyenne
    :
    :
    you probably forgot to make your instance of access visible-

    try this, assumes you have a mdb file - acc2000.mdb


    Option Explicit


    'requires reference to Microsoft Access 10.0 Object Library

    'Const cPath = "c:vb6automationaccessacc2000.mdb"
    Dim cPath As String

    'Dim AccessApp As Application
    Dim AccessApp As Access.Application


    Private Sub cmd1StartAccess_Click()
    'START ACCESS
    Set AccessApp = New Access.Application
    AccessApp.Visible = True '****************VISIBLE !!
    AccessApp.OpenCurrentDatabase cPath
    AccessApp.DoCmd.Maximize
    End Sub

    Private Sub cmd2OpenReport_Click()
    'OPEN A REPORT
    AccessApp.DoCmd.OpenReport "report1", acViewPreview
    'CLOSE A REPORT
    'AccessApp.DoCmd.Close acReport, "report1"
    'RUN A MACRO
    'AccessApp.DoCmd.RunMacro "MyMacro"
    End Sub

    Private Sub cmd3CloseAccess_Click()
    'QUIT ACCESS
    AccessApp.CloseCurrentDatabase
    AccessApp.Quit
    Set AccessApp = Nothing
    End Sub

    Private Sub Form_Load()
    'PATH TO A SAMPLE ACCESS MDB FILE
    cPath = App.Path + "acc2000.mdb"
    End Sub
  • CheyenneCheyenne Member Posts: 28
    : : Hi,
    : : I'll try to open an existing database from VB6. the database opens
    : : but won't show.
    : : My general idee was to open the database from Vb and then by opening
    : : the base the autoexec macro started.
    : : I see that the database is open on the .ldb extencion, but nothing
    : : seems to start.
    : : Please give me a helping hand
    : : Cheyenne
    : :
    : :
    : you probably forgot to make your instance of access visible-
    :
    : try this, assumes you have a mdb file - acc2000.mdb
    :
    :
    : Option Explicit
    :
    :
    : 'requires reference to Microsoft Access 10.0 Object Library
    :
    : 'Const cPath = "c:vb6automationaccessacc2000.mdb"
    : Dim cPath As String
    :
    : 'Dim AccessApp As Application
    : Dim AccessApp As Access.Application
    :
    :
    : Private Sub cmd1StartAccess_Click()
    : 'START ACCESS
    : Set AccessApp = New Access.Application
    : AccessApp.Visible = True '****************VISIBLE !!
    : AccessApp.OpenCurrentDatabase cPath
    : AccessApp.DoCmd.Maximize
    : End Sub
    :
    : Private Sub cmd2OpenReport_Click()
    : 'OPEN A REPORT
    : AccessApp.DoCmd.OpenReport "report1", acViewPreview
    : 'CLOSE A REPORT
    : 'AccessApp.DoCmd.Close acReport, "report1"
    : 'RUN A MACRO
    : 'AccessApp.DoCmd.RunMacro "MyMacro"
    : End Sub
    :
    : Private Sub cmd3CloseAccess_Click()
    : 'QUIT ACCESS
    : AccessApp.CloseCurrentDatabase
    : AccessApp.Quit
    : Set AccessApp = Nothing
    : End Sub
    :
    : Private Sub Form_Load()

    : 'PATH TO A SAMPLE ACCESS MDB FILE
    : cPath = App.Path + "acc2000.mdb"
    : End Sub
    :

    Thanx, you're right, if forgot to declare the instance

    Cheyenne
Sign In or Register to comment.