Lavsa, Rich
Rich_Lavsa at pghcorning.com
Fri Feb 7 12:04:00 CST 2003
I haven't been following this thread until now.. but if you want to simply add a column to an existing table can't you simply write an Alter Table statement and kick it off in code or even in a data definition query? go into help and look at Alter Table statement there are some good examples there rich -----Original Message----- From: Gustav Brock [mailto:gustav at cactus.dk] Sent: Friday, February 07, 2003 12:48 PM To: Shamil Salakhetdinov Subject: Re: [AccessD] Acc97: Creating GUID Autonumber using VBA code... Hi Shamil > Is the subj described somewhere? Should I RTFM with more attention and > accuracy? > The following code doesn't produce desired result: > Dim dbs As DAO.Database > Dim tdf As DAO.TableDef > Dim fld As DAO.Field > Set dbs = CurrentDb > Set tdf = dbs.TableDefs("tblTest") > Set fld = tdf.CreateField("fldTest", dbGUID, 16) > fld.Properties("DefaultValue") = "GenGUID()" > tdf.Fields.Append fld > dbAutoIncrField value for Attributes property can't be used at all producing > error 3001 - Invalid argument > Any solutions? First, this should be adequate: Set fld = tdf.CreateField("fldTest", dbGUID) Next, I don't think you can do this other than manually in design view, indeed not if you wish to have two autonumber columns. This may be one of the situations where you need to create an empty table with the required structure and copy it to the backend. If you find out a method to add the field in code, please share. /gustav