how to programmatically create linked table w/o access 
Author Message
 how to programmatically create linked table w/o access

How can I create a link to another database (DBF) programmatically without
opening Access?
Are there any VB, VBA or SQL solutions?

Thanks,
    Justin



Thu, 23 Dec 2004 06:37:20 GMT  
 how to programmatically create linked table w/o access
Hi Justin,

as far as I know you have to open Access. A form or module
linked to by the autoexec module can open your form or
module and then create the links.
Best is using  the Docmd.TransferDatabase
Command.
Its syntax is:
DoCmd.TransferDatabase [Transfertype], Databaseformat,
DataBaseName[, Objekttype], Name in Source Database, Name
in destination database[, structureOnly][, password]

E.g.:
DoCmd.TransferDatabase acImport, "Microsoft
ACCESS", "c:\me.mdb", acTable, "Table1", "NewTab"

imports the Table "Table1" from "c:\me.mdb" into the
table "NewTab" in your database.

Hope that helps,

Christoph

Quote:
>-----Original Message-----
>How can I create a link to another database (DBF)

programmatically without
Quote:
>opening Access?
>Are there any VB, VBA or SQL solutions?

>Thanks,
>    Justin

>.



Sat, 25 Dec 2004 16:43:59 GMT  
 how to programmatically create linked table w/o access

Quote:
> How can I create a link to another database (DBF) programmatically
> without opening Access?
> Are there any VB, VBA or SQL solutions?

Depends what you want to do:

  set db = dbengine.workspaces(0).opendatabase(strDataBaseFileName)
  set rs = db.openrecordset( _
    "select * from mytable where myrecord=2;", _
    dbopensnapshot, dbforwardonly)
  debug.print "Gotcha: "; rs!mysurprisingfield

  rs.close
  db.close

Or
  select * from mytable
  into myothertable in "c:\myotherdatabase.mdb"
  where myrecordid = 2;

etc. etc. etc...

Does that help?

Tim F



Sun, 26 Dec 2004 02:22:51 GMT  
 how to programmatically create linked table w/o access
unrelated question:

why did you choose this line:
  set db = dbengine.workspaces(0).opendatabase(strDataBaseFileName)

over

set db = currentdb()

thanks
JamesSF


Quote:

> > How can I create a link to another database (DBF) programmatically
> > without opening Access?
> > Are there any VB, VBA or SQL solutions?

> Depends what you want to do:

>   set db = dbengine.workspaces(0).opendatabase(strDataBaseFileName)
>   set rs = db.openrecordset( _
>     "select * from mytable where myrecord=2;", _
>     dbopensnapshot, dbforwardonly)
>   debug.print "Gotcha: "; rs!mysurprisingfield

>   rs.close
>   db.close

> Or
>   select * from mytable
>   into myothertable in "c:\myotherdatabase.mdb"
>   where myrecordid = 2;

> etc. etc. etc...

> Does that help?

> Tim F



Wed, 29 Dec 2004 01:37:11 GMT  
 how to programmatically create linked table w/o access


Quote:

> why did you choose this line:
>   set db = dbengine.workspaces(0).opendatabase(strDataBaseFileName)

> over

> set db = currentdb()

He wanted to open a different database.

If he needed to manipulate the current db, then that would work fine.

If he needed to open with different username, password etc. then he'd have
to create a new workspace as well.

Diff'rnt strokes for diff'rnt needs... or sumthing!

Tim F



Wed, 29 Dec 2004 02:46:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Creating and deleting referential table links programmatically

2. How do I programmatically create a linked FoxPro table

3. Linking Access Tables in Different *.mdb Files, Populating an Access Table From Several Others

4. Linking Access Tables in Different *.mdb Files, Populating an Access Table From Several Others

5. Access 2000 VBA/SQL - cannot create pseudo-index on linked SQL Server table

6. Create a linked table in Access

7. creating link tables in access using .net

8. Create a Linked table to external text file in Access

9. creating linked tables in access

10. Creating Table Links in Access.

11. Need to link a table to a text file programmatically

12. Programmatically remove linked tables

 

 
Powered by phpBB® Forum Software