[AccessD] Create and Link Table in external database
Stuart McLachlan
stuart at lexacorp.com.pg
Tue Jun 7 19:37:08 CDT 2016
Have you tried it with the DAO. back in
"Dim tdfLinked As DAO.TableDef"
On 7 Jun 2016 at 15:29, Rocky Smolin wrote:
> tdfLinked.Attributes = dbAttachedTable also generates an error 3001
> Invalid argument. (I get enough of those on OT)
>
> I added it before: dbFrontEnd.TableDefs.Append tdfLinked
>
> Scoured the internets on this but no cigar. Any other ideas?
>
> TIA
>
> Rocky
>
>
>
>
> -----Original Message-----
> From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf
> Of Stuart McLachlan Sent: Tuesday, June 07, 2016 3:13 PM To: Access
> Developers discussion and problem solving Subject: Re: [AccessD]
> Create and Link Table in external database
>
> "If the object you're appending isn't complete ... using the Append
> method triggers a run-time error." You have not specified any
> Attributes.
>
> Try adding: tdfLinked.Attributes = dbAttachedTable
>
> --
> Stuart
>
> 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
>
> --
> 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