注册 登录
编程论坛 ACCESS论坛

请问怎么让ID号自动填充,从200开始增1

andy292 发布于 2016-11-15 14:47, 3941 次点击

用什么SQL语句呢,让ID号自动填充,从200开始增1,我已经有2000条数据
4 回复
#2
andy2922016-11-15 14:49
alter table News2 alter column [ID] counter(200,1)
#3
andy2922016-11-15 14:51
可是常常出 无效的字段数据类型  错误
#4
andy2922016-11-16 20:04
Sub first()
  Dim aa_w As adodb.Connection
  Set aa_w = CurrentProject.Connection
  Dim bb_w As adodb.Recordset
  Set bb_w = New adodb.Recordset
  bb_w.Open "news2", aa_w, 3,3
  cc_w = 200
  For time_k = 1 To 1911
  bb_w!id = cc_w
 bb_w.MoveNext
 cc_w = cc_w + 1
 Next time_k
  bb_w.Close
  aa_w.Close
  Set bb_w = Nothing
  Set aa_w = Nothing
End Sub

自已写VBA代码修改了 字段ID中的信息
#5
andy2922017-02-06 22:26
Sub OrderByX()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind
    ' on your computer.
    Set dbs = OpenDatabase("Northwind.mdb")

    ' Select the last name and first name values from
    ' the Employees table, and sort them in descending
    ' order.
    Set rst = dbs.OpenRecordset("SELECT LastName, " _
        & "FirstName FROM Employees " _
        & "ORDER BY LastName DESC;")
   
    ' Populate the Recordset.
    rst.MoveLast
   
    ' Call EnumFields to print recordset contents.
    EnumFields rst, 12

    dbs.Close

End Sub


让ACCESS表 任意字段排序的VBA代码
1