Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2004
    Sunshine Coast, Australia

    Question Unanswered: Create new database feature

    Hi, I want to do the following:

    1. Create a blank access database
    2. Copy tables from one database to this blank one, copying structure only, not tables
    3. Do a compact and repair on the database created.

    Now, we use a access DB for the front end and an access DB for the back end.

    I want to do this on the backend database, not the front end database.

    I pretty much understand the concept of importing tables using the transfer command but how can I create a blank database within VBA code?

    Thanking you all in advance

    - Mark

  2. #2
    Join Date
    Aug 2002
    Northampton, England
    have a look at the NewCurrentDatabase method in the help files

  3. #3
    Join Date
    Feb 2004
    Chicago, IL
    What about copying the existing file, deleting all the data in each table and then compacting? Might be easier to program. The compact will reset any autonumber fields you have back to 1.

  4. #4
    Join Date
    Dec 2003

    Give this a shot

    Once you create a copy of the DB try this.

    This cycles through each table in the database, dynamically creates an SQL statement and deletes all records for not system tables.

    Public Sub CleanItOut()
    Dim tDef As TableDef
    Dim db As Database
    Dim sql As String

    Set db = CurrentDb

    For Each tDef In db.TableDefs
    If Not Left(tDef.Name, 4) = "msys" Then
    sql = "DELETE * FROM " & tDef.Name
    db.Execute (sql)
    End If
    Next tDef
    set db = nothing
    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