Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a new table in a linked database 1

Status
Not open for further replies.

BusMgr

IS-IT--Management
Joined
Aug 21, 2001
Messages
138
Location
US
In upgrading my database, I have created three new tables that are linked between the front end and the back end. I currently run code that checks the link each time that the database is opened, but it only gives an error message if any of the linked tables are not found.

I want to be able to create (copy & paste if best way) the new tables from the front end to the backend. I am also concerned about inheriting all the properties of the table, including the relationships between the tables that currently exist and the new tables.

Can someone point me in the right direction? It will have to be done in the VBA code behind the db.

Thanks for any help or direction in advance.

BusMgr
 
Hello,

You could use code similar to this to import your tables:

DoCmd.SetWarnings False
Dim dbs As Database, rel As Relation, fld As Field
Set dbs = DBEngine(0)(0)

'Import tables from other database
DoCmd.TransferDatabase acImport, "Microsoft Access", [Text19], acTable, "customers_table", "customers_table", False


You can use code like this to create relationships:

'Create relationship
Set rel = dbs.CreateRelation("CustomerID1", "invoices", "customers_table", dbRelationDontEnforce)
Set fld = rel.CreateField("inv_client")
fld.ForeignName = "name"
rel.Fields.Append fld
dbs.Relations.Append rel
dbs.Relations.Refresh
Set dbs = Nothing


These are examples pulled straight out of one of my databases, but it should point you in a good direction for importing a table and creating a relationship.

Garry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top