Oleg_123 at xuppa.com
Oleg_123 at xuppa.com
Mon Feb 10 10:19:02 CST 2003
this line fails, for sme reason it doesn't seem to work, does it require
ADO conn by any chance
his works for adding a new filed to an existing table, but, I can't attach
line anywhere... .Attributes = dbAutoIncrField
Dim dbDM As Database
Dim tbGAP As TableDef
Dim fldLoop As Field
Set dbDM = CurrentDb
'Set tbGAP = dbDM.CreateTableDef("Andy")
Set tbGAP = dbDM.TableDefs("Andy")
With tbGAP
.Fields.Append .CreateField("PriKeyy", dbLong)
End With
> Hi Oleg
>
> I can't see why this shouldn't work.
> However, you may try this variation:
>
> Set fld = tbl.CreateField("YourField")
> fld.Type = dbLong
> fld.Attributes = dbAutoIncrField
> tbl.Fields.Append fld
>
> Stepping through the code, which line failes?
>
> /gustav
>
>
>> 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
>
> _______________________________________________
> 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/