Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2002
    Richland, Washington

    Question Unanswered: OpenCurrentDatabase in Access2002

    Access 2002 messed up my app! (OK, that's too strong. I should say
    that A2002 seems to have changed the functionality of the
    OpenCurrentDatabase method. So now my application is kindof *messy*).
    Let me explain:

    I have an app that exports some tables from the current DB to another
    one on a floppy with the following code:

    Dim objAccess As New Access.Application
    With objAccess
    .OpenCurrentDatabase (CurrentProject.FullName)
    .DoCmd.TransferDatabase acExport, "Microsoft Access", _
    strDBTo, acTable, strTableNameSource, strTableNameDest
    End With

    This has been working fine in Access2K. (It loops through this
    procedure a number of times for each table exported.)

    The problem is that recently I needed to put the app on a machine
    running Access2002. NOW, when the app loops through this code, the
    openCurrentDatabase function actually OPENS up a NEW window with a
    second copy of the current DB, then it CLOSES again. The effect of
    this is a very unsightly *flashing* on and off of new windows as the
    code loops through this procedure.

    This is rather irritating, so if someone would be so kind as to
    explain why this happens in 2002 & not 2K (and what I might do about
    it) I would greatly appreciate it!

    Thank you!

    P.S. I'm something of a beginner in Access, so perhaps the way I did
    this in A2K wasn't the best way. (But it DID work!) If there is
    another, more efficient or preferable method to do this, I'd certainly
    like to know!

  2. #2
    Join Date
    Nov 2002
    San Francisco

    Talking Re: OpenCurrentDatabase in Access2002

    do you need to export content of each Table from opened MDB into Excel?

    this small code exports every table, which start with letters TBL into Excel.... you can do the same with Queries - use QUERYDEF instead of TABLEDEF.

    Sub Export()

    For Each myTable In CurrentDb.TableDefs

    If Left(myTable.Name, 3) = "tbl" Then
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, myTable.Name, FileName:="c:\test.xls", HasFieldNames:=True
    End If

    End Sub


Posting Permissions

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