|
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim i As Long, X As Long
Set db = CurrentDb
Set rs = db.OpenRecordset("商品", dbOpenDynaset)
X = Me.番号開始
For i = 1 To CLng(Replace(Me.No終了, "A", "")) - (CLng(Replace(Me.No開始, "A", "")) - 1)
rs.AddNew
rs![No] = "A" & CStr((CLng(Replace(Me.No開始, "A", "")) - 1) + i)
rs![種類] = Me.種類
If i < Me.番号数 Then
rs![番号] = Me.番号開始
ElseIf i Mod Me.番号数 = 0 Then
X = X + 1
rs![番号] = Format(X, "000")
Else
rs![番号] = Format(X, "000")
End If
rs.Update
Next i
rs.Close: Set rs = Nothing
db.Close: Set db = Nothing
MsgBox "終わったよ"
こんな感じでしょうか?
|
|