2011年7月10日日曜日

←←←/Access/付番

Public Function 付番()
    Dim db As Database
    Dim t   As  RecordSet
    Dim i    As  Integer

    Set  db  =  CurrentDb
    Set  t    =  db.OpenRecordSet("SELECT * FROM あ ORDER BY SEQ DESC;")

    If  t.EOF  =  True  Then
        MSGBOX "レコードがありません"
    Else
        t.MoveFirst
        Do Until t.EOF
           t.Edit
           i  =  i  +  1
           t!Auto = Right( (1000000 + i ) , 5 )
           t!Update
           t.MoveNext
        LOOP
    End If

    MsgBox "処理終了" & i & "件"
    t.Close
    db.Close
    Set t = Nothing
    Set db = Nothing
End Function

0 件のコメント:

コメントを投稿