Create Table / Modify Table in remote database

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jozef

    #1

    Create Table / Modify Table in remote database

    I'm using Access XP.

    I'm trying to create a table, modify a table, create in index, and create a
    relationship in a remote database in code from the program database.

    I know how to create and manipulate resident tables using code but not a
    remote or attached database.

    Any help you could provide would be greatly appreciated

    Thank you!
    Jo


  • Chuck Grimsby

    #2
    Re: Create Table / Modify Table in remote database

    You need to open the remote database as an object.

    Dim objAcc As Access.Applicat ion
    Dim extDB As DAO.Database
    Set objAcc = GetObject(strRe moteDB_FileName )
    Set extDB = objAcc.CurrentD b
    [color=blue]
    >From there, you can do anything you need to do in extDB (the "remote"[/color]
    database) as if it was the local database. Just remember to preface
    your commands with "extDB." or "objAcc." (depending upon what level you
    need to operate at) so Access doesn't try to do it in the local DB.

    objAcc.DoCmd.De leteObject <whatever>
    or
    extDB.Execute <SQL string>,dbFailO nError

    As always, remember to close and set to nothing your objects.

    Oh, and a warning... Remember to make a _copy_ of the remote database
    before doing anything to it! This will give you a chance to abort
    whatever you are doing if (when!) something unexpected happens (and
    experience says: it will.)

    Comment

    • Jozef

      #3
      Re: Create Table / Modify Table in remote database

      Thanks Chuck, I'll give that a try.


      "Chuck Grimsby" <c.grimsby@worl dnet.att.net> wrote in message
      news:1116581114 .544507.224860@ g49g2000cwa.goo glegroups.com.. .[color=blue]
      > You need to open the remote database as an object.
      >
      > Dim objAcc As Access.Applicat ion
      > Dim extDB As DAO.Database
      > Set objAcc = GetObject(strRe moteDB_FileName )
      > Set extDB = objAcc.CurrentD b
      >[color=green]
      >>From there, you can do anything you need to do in extDB (the "remote"[/color]
      > database) as if it was the local database. Just remember to preface
      > your commands with "extDB." or "objAcc." (depending upon what level you
      > need to operate at) so Access doesn't try to do it in the local DB.
      >
      > objAcc.DoCmd.De leteObject <whatever>
      > or
      > extDB.Execute <SQL string>,dbFailO nError
      >
      > As always, remember to close and set to nothing your objects.
      >
      > Oh, and a warning... Remember to make a _copy_ of the remote database
      > before doing anything to it! This will give you a chance to abort
      > whatever you are doing if (when!) something unexpected happens (and
      > experience says: it will.)
      >[/color]


      Comment

      Working...