[AccessD] Create and Link Table in external database
Rocky Smolin
rockysmolin at bchacc.com
Tue Jun 7 23:26:35 CDT 2016
Really? No spaces? I always spaced out everything because the spaces never
were critical - not in any SQL type stuff.
Anyway the TransferDatabase thing worked beautifully. Is there any
advantage, you think, of one over the other?
r
-----Original Message-----
From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
Stuart McLachlan
Sent: Tuesday, June 07, 2016 6:48 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Create and Link Table in external database
Sheesh! After a lot of playing around, eventually, it was so simple!
You don't need to specify anything additional info, you just need to get
what you are currently specifying correct :-)
Change:
tdfLinked.Connect = ";Database = " & gstrDatabaseName
TO:
tdfLinked.Connect = ";Database=" & gstrDatabaseName
i.e. without the two spaces.
On 7 Jun 2016 at 14:02, Rocky Smolin wrote:
> Dear List:
>
> I am trying to create and link to a new table in an external database.
> The create part works fine but the linking part fails on the last
> line: dbFrontEnd.TableDefs.Append tdfLinked, with an Error 3001
> Invalid argument, but I can't see why.
>
> I tried changing Dim tdfLinked As TableDef to Dim tdfLinked As
> DAO.TableDef but same result. Here's the code:
>
> Dim db As DAO.Database
> Dim dbFrontEnd As DAO.Database
>
> Dim wrk As DAO.Workspace
>
> Dim tdf As DAO.TableDef
> Dim tdfLinked As TableDef
>
> ' Create Table
> Set tdf = db.CreateTableDef("tblPODetailRemarks")
> Set fld = tdf.CreateField("fldPODetailRemarksID", dbLong)
> fld.Attributes = dbAutoIncrField
> tdf.Fields.Append fld
>
> Set ind = tdf.CreateIndex("PrimaryKey")
> With ind
> .Fields.Append .CreateField("fldPODetailRemarksID")
> .Unique = False
> .Primary = True
> End With
> tdf.Indexes.Append ind
>
> Set fld = tdf.CreateField("fldPODetailRemarks", dbText, 255)
> tdf.Fields.Append fld
>
> db.TableDefs.Append tdf
>
> ' Link Table
> Set dbFrontEnd = CurrentDb
> Set tdfLinked = dbFrontEnd.CreateTableDef("tblPODetailRemarks")
> tdfLinked.Connect = ";Database = " & gstrDatabaseName
> tdfLinked.SourceTableName = "tblPODetailRemarks"
> dbFrontEnd.TableDefs.Append tdfLinked
>
> Does anyone see what I'm doing wrong?
>
> MTIA
>
> Rocky Smolin
> Beach Access Software
> 760-683-5777
> www.bchacc.com <http://www.bchacc.com/> www.e-z-mrp.com
> <http://www.e-z-mrp.com/>
> Skype: rocky.smolin
>
> --
> 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