Public Function 連番付加()
Dim db As Database
Dim t As RecordSet
Dim cnt As Long
Dim 番号 As String
Set db = CurrentDb
Set t = db.OpenRecordSet("SELECT F1.* FROM F1 ORDER BY F1.m1 , F1.m2;")
cnt = 1
If t.EOF = True Then
MsgBox"レコードがありません"
Else
t.MoveFirst
Do Until t.EOF
t.Edit
番号 = Format( CLng ( cnt ) , String ( CLng(6), "0" ))
t!番号 = "A1" & 番号
t.Update
cnt = cnt + 1
t.MoveNext
Loop
End If
MsgBox"処理終了" & cnt - 1 & "件"
t.Close
db.Close
Set t = Nothing
Set db = Nothing
End Function
0 件のコメント:
コメントを投稿