[AccessD] Adding a linked table in code

Max Wanadoo max.wanadoo at gmail.com
Thu Jun 5 13:59:16 CDT 2008


Well typically it is only required when:
1. New tables have been added to the BE
2. The User (programmer/me) wants to work on a local BE instead of the live
(networked) BE.  I can then just jump between the two.
3. Time is depending on the number of  tables but not very long.
NB. I change the backgroun color of the main menu to make it clear whether I
am working with LIVE or LOCAL data.

Max
 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Thursday, June 05, 2008 7:42 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Adding a linked table in code

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
> 
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list