Andy Lacey
andy at minstersystems.co.uk
Sat Feb 8 05:38:01 CST 2003
Oleg Still don't know why you're getting this. Rich's answer's the same as mine and obviously works =for him too. Put it in debug and see what it is that's causing it. Oh, and as I asked before, which version are you using? Andy Lacey http://www.minstersystems.co.uk > -----Original Message----- > From: accessd-admin at databaseadvisors.com > [mailto:accessd-admin at databaseadvisors.com] On Behalf Of > Oleg_123 at xuppa.com > Sent: 07 February 2003 21:08 > To: accessd at databaseadvisors.com > Subject: RE: [AccessD] adding field to table via code > > > doesn't work -- I get a "type mismatch error" :-/ > > > For an AutoNumber field, try this syntax: > > > > Set fldNewField = tdfNewTable.CreateField("BatchID", dbLong) > > ' make it an AutoNumber > > fldNewField.Attributes = dbAutoIncrField > > ' append BatchID field > > tdfNewTable.Fields.Append fldNewField > > > > Its worked for me in the past. > > > > Rich > > > > -----Original Message----- > > From: Oleg_123 at xuppa.com [mailto:Oleg_123 at xuppa.com] > > Sent: Wednesday, February 05, 2003 1:20 PM > > To: accessd at databaseadvisors.com > > Subject: RE: [AccessD] adding field to table via code > > > > > > Thank you, the first one works , the second one (wherei try > to make a > > field ino autonumber, doesn't) Private Sub Command29_Click() > > > > Dim dbDM As Database > > Dim tbGAP As TableDef > > Dim fldLoop As Field > > > > Set dbDM = CurrentDb > > Set tbGAP = dbDM.CreateTableDef("Andy") > > > > With tbGAP > > .Fields.Append .CreateField("PriKey", dbInteger) > > End With > > > > dbDM.TableDefs.Append tbGAP > > > > End Sub > > > > Private Sub Command29_Click() > > > > Dim dbDM As Database > > Dim tbGAP As TableDef > > Dim fldLoop As Field > > > > Set dbDM = CurrentDb > > Set tbGAP = dbDM.TableDefs("Andy") > > > > With tbGAP > > .Fields.Append .CreateField("PriKey", dbAutonumber) > > End With > > > > dbDM.TableDefs.Append tbGAP > > > > End Sub > > > > ---------------------------- > > > > > > > > > > > > ----------------------------------------- > > Send a Xuppa Valentine to Your Sweetheart today! > > http://www.xuppa.com/greet/ > > > > > > _______________________________________________ > > 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 > > > > ----------------------------------------- > Send a Xuppa Valentine to Your Sweetheart today! http://www.xuppa.com/greet/ _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com