I am trying to update some existing database tables by inserting some new fields in a set order within the existing table. The issue I am having is it inserts the new field at the existing position counts and not at the new positions based on accumulative count.
For example field 24 is being inserted at the end of the table which is really field 28 when all four of the new fields are inserted. How can I refresh the table so that the fields are inserted at the right location
(Hope this is clear)
For example field 24 is being inserted at the end of the table which is really field 28 when all four of the new fields are inserted. How can I refresh the table so that the fields are inserted at the right location
(Hope this is clear)
Code:
Dim db As DAO.Database
Dim Tbl As DAO.TableDef
Dim fld As DAO.Field
Dim Prop As DAO.Property
Set db = CurrentDb()
Set Tbl = db.TableDefs("Data Entry1")
'***Add NEW Columns***
Tbl.Fields.Refresh
If Tbl.Fields(10).Name <> "Branch/Ticket" Then
Set fld = Tbl.CreateField("Branch/Ticket", dbText, 10)
fld.OrdinalPosition = 10
Tbl.Fields.Append fld
fld.Properties("Required").Value = False
fld.Properties("AllowZeroLength").Value = True
End If
Tbl.Fields.Refresh
If Tbl.Fields(14).Name <> "Auth/PO Number" Then
Set fld = Tbl.CreateField("Auth/PO Number", dbText, 255)
fld.OrdinalPosition = 14
Tbl.Fields.Append fld
fld.Properties("Required").Value = False
fld.Properties("AllowZeroLength").Value = True
End If
Tbl.Fields.Refresh
Set Tbl = db.TableDefs("Data Entry1")
If Tbl.Fields(18).Name <> "Invoiced Amount" Then
Set fld = Tbl.CreateField("Invoiced Amount", dbCurrency)
fld.OrdinalPosition = 18
Tbl.Fields.Append fld
fld.Properties("Required").Value = False
End If
Tbl.Fields.Refresh
If Tbl.Fields(24).Name <> "Amount Paid" Then
Set fld = Tbl.CreateField("Amount Paid", dbCurrency)
fld.OrdinalPosition = 24
Tbl.Fields.Append fld
fld.Properties("Required").Value = False
End If
Comment