jwcolby
jwcolby at colbyconsulting.com
Thu Jun 5 13:42:19 CDT 2008
How long do these docmd.xxx take? John W. Colby www.ColbyConsulting.com Max Wanadoo wrote: > Hi Don, > > I just do this:- > > If bUserWantsNetwork Then > DoCmd.TransferDatabase acLink, "Microsoft Access", conDataPathNetwork & > conDatabaseMain, acTable, "mcmSystemInfo", "mcmSystemInfo", False, False > Else > DoCmd.TransferDatabase acLink, "Microsoft Access", conDataPathLocal & > conDatabaseMain, acTable, "mcmSystemInfo", "mcmSystemInfo", False, False > End If > > The above opens a table which contains details of all other tables to link. > It then runs through them all and links them in, thus: > > DoCmd.TransferDatabase acLink, "Microsoft Access", strPathMain, > acTable, strLinkThisTable, strLinkThisTable, False, False > > Max > > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of McGillivray, Don > [IT] > Sent: Thursday, June 05, 2008 7:17 PM > To: Access Developers discussion and problem solving > Subject: [AccessD] Adding a linked table in code > > This seems like it ought to be simple, but I'm having trouble, and the > Access "help" doesn't. Running Access 2003 SP3. > > All I want to do is to add a linked table to my db using code. Here's what > I have so far: > > Dim db As DAO.Database, tdf As DAO.TableDef Set db = CurrentDB() With db > Set tdf = .CreateTableDef("tblLocalTableName", dbAttachedTable, > "tblRemoteTableName", _ > "D:\Path\RemoteDB.mdb") > .TableDefs.Append tdf > .TableDefs.Refresh > End With > Set db = Nothing > > The error occurs on the "Set tdf . . . " line, and is "3001 - Invalid > argument". > > If I remove the Attributes argument (dbAttachedTable), I get an error on the > ".TableDefs.Append" line, saying "3264 No field defined--cannot append > tabeldef or index". > > Seems like I ought to be able to tell it that I'm attaching to an existing > table in an existing db, but obviously I'm doing something wrong here. I've > checked to be sure that the specified table exists in the remote db, and > I've tried appending ";DATABASE=" to the connect string argument, all to no > avail. > > Any advice out there? > > > Thanks! > > Don McGillivray > > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com >