|
▼はじめまして さん:
カタカナだったフィールド名[コード]を
[CODE]に変更してあります。
Sub Test1()
Dim db As Database
Dim rstMain As Recordset
Dim rstSub As Recordset
Dim rstNG_D As Recordset
Dim nChk As Integer
Set db = CurrentDb()
Set rstMain = db.OpenRecordset("T_顧客", dbOpenDynaset)
Set rstSub = db.OpenRecordset("T_情報", dbOpenDynaset)
Set rstNG_D = db.OpenRecordset("NG_D", dbOpenDynaset)
Do Until rstMain.EOF
rstSub.FindFirst "[CODE]=" & rstMain![CODE]
If rstSub.NoMatch = True Then
rstNG_D.AddNew
rstNG_D![CODE] = rstMain![CODE]
rstNG_D.Update
Else
'Do Until rstSub.EOF
→変更 Do Until rstSub.NoMatch
nChk = rstSub![CHK1]
'// この処理は省略・・
'rstSub.MoveNext
rstSub.FindNext "[CODE]=" & rstMain![CODE]
Loop
End If
rstMain.MoveNext
Loop
→追加 rstNG_D.Close: Set rstNG_D = Nothing
rstSub.Close: Set rstSub = Nothing
rstMain.Close: Set rstMain = Nothing
End Sub
こんな感じでいかがでしょうか?
|
|