Public Function 格段毎付番()
Dim db As Database
Dim t As RecordSet
Dim i As Integer
Dim myStr As String
Set db = CurrentDb
Set t = db.OpenRecordSet("SELECT * FROM あ ORDER BY SEQ;")
myStr = ""
If t.EOF = True Then
MsgBox "レコードがありません"
Else
t.MoveFirst
Do Until t.EOF
If t!切替位置 <> myStr Then
myStr = t!切替位置
i = 1
t.Edit
t!連番 = Right((100000 + i), 5 )
t.Update
Else
t.Edit
i = i + 1
t!連番 = Right((100000 + i ),5 )
t.Update
End if
t.MoveNext
Loop
End If
MsgBox "処理終了" & i & "件"
t.Close
db.Close
Set t = Nothing
Set db = Nothing
End Function
0 件のコメント:
コメントを投稿