Gustav Brock
gustav at cactus.dk
Fri Feb 7 11:48:01 CST 2003
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