V
Vatter47
In order to be able to synchronize 2 databases, I need to convert an
autoincrement field to a standard integer field. I'm using the following
code:
Set tbl = catProj.Tables("Termine")
Set col = tbl.Columns("T_NR")
If col.Properties("Autoincrement") = True Then
tbl.Indexes.Delete "PrimaryKey"
col.Name = "xID"
set col = Nothing
CreateColumn catProj, tbl.Name, "T_NR", adInteger
DoCmd.RunSQL "UPDATE [Termine] SET T_NR = xID;"
tbl.Columns.Delete "xID"
CreateIndex catProj, tbl.Name, "myPrimaryKey", "T_NR", _
adIndexNullsDisallow, adSortAscending, True, True
End If
This all works fine until the new index should be created. I get the
following error message:
Error -2147467259: Index or primary key cannot contain a Null value
Since the old field was the primary index field the new one cannot
contain any Nulls.
Where is my problem?
Thanks for helping
Walter
autoincrement field to a standard integer field. I'm using the following
code:
Set tbl = catProj.Tables("Termine")
Set col = tbl.Columns("T_NR")
If col.Properties("Autoincrement") = True Then
tbl.Indexes.Delete "PrimaryKey"
col.Name = "xID"
set col = Nothing
CreateColumn catProj, tbl.Name, "T_NR", adInteger
DoCmd.RunSQL "UPDATE [Termine] SET T_NR = xID;"
tbl.Columns.Delete "xID"
CreateIndex catProj, tbl.Name, "myPrimaryKey", "T_NR", _
adIndexNullsDisallow, adSortAscending, True, True
End If
This all works fine until the new index should be created. I get the
following error message:
Error -2147467259: Index or primary key cannot contain a Null value
Since the old field was the primary index field the new one cannot
contain any Nulls.
Where is my problem?
Thanks for helping
Walter