[AccessD] Create and Link Table in external database
Stuart McLachlan
stuart at lexacorp.com.pg
Tue Jun 7 20:47:44 CDT 2016
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
>
More information about the AccessD
mailing list