Oleg_123 at xuppa.com
Oleg_123 at xuppa.com
Mon Feb 10 09:09:00 CST 2003
Hey Andy
Nope, not working :))
I assume that having it done in function, and saying
OpenDatabase("YoutMDB") instead of CurrentDB made no fifference but i did
it anyway.
Still getting that dreadful type mismatch error..
(I was able to just the the "Pri Key field, without numbers in it..)
going to try again now...
> Well I just checked it in A2K and it works fine. I'm reposting the code
> so you can just copy and paste it and try it agin, obviously
> substituting your MDB, table and field names.
>
> Function test()
> Dim db As Database
> Dim tbl As TableDef
> Dim fld As Field
>
> Set db = OpenDatabase("YoutMDB")
> Set tbl = db.TableDefs("YourTable")
>
> Set fld = tbl.CreateField("YourField", dbLong)
> fld.Attributes = dbAutoIncrField
> tbl.Fields.Append fld
>
> Set fld = Nothing
> Set tbl = Nothing
> Set db = Nothing
>
>
> End Function
>
> And Pancake Day is Shrove Tuesday. Traditionally it's the using up of
> all of the eggs you have in the house before commencing the 40-day fast
> of Lent (because they would go bad during the time you were fasting).
> And the eggs were used by making batter and frying it, ie pancakes.
> Nowadays I doubt if many do the fasting but we all enjoy the pancakes.
>
> 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: 08 February 2003 23:21
>> To: accessd at databaseadvisors.com
>> Subject: RE: [AccessD] adding field to table via code
>>
>>
>> hi Andy,
>>
>> I notoced, don't know why...I have 2000 version
>> I also meant to ask you, what is "Pancake Day" ? :)
>>
>> --------------
>>
>> > 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
>> >
>> > _______________________________________________
>> > 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
>
> _______________________________________________
> 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/