Private Sub Form_Close() DoCmd.SetWarnings 0 Dim DB As DAO.Database Dim wrs As DAO.Recordset Dim hrs As DAO.Recordset Dim prs As DAO.Recordset Dim n(100) As Long Dim NNB(100) As Long Dim i As Long Dim sql As String sql = "SELECT 受け取った人.[年], 受け取った人.[NO] FROM [受け取った人] WHERE (((受け取った人.[年])=[Forms].[年賀メール].[m年]));" Set DB = DBEngine.Workspaces(0).Databases(0) Set crs = DB.OpenRecordset("ワークテーブル") '年賀メール Set hrs = DB.OpenRecordset(sql) '受け取った人 Set prs = DB.OpenRecordset("受け取った人") '受け取った人 '比較対象作成 hrs.MoveFirst i = 0 Do Until hrs.EOF i = i + 1 n(i) = hrs("年") NNB(i) = hrs("NO") Loop '主処理 crs.MoveFirst Do Until crs.EOF For i = 1 To 100 If crs("年") = n(i) And crs("NO") = NNB(i) Then GoTo t Next i prs.AddNew prs("年") = crs("年") prs("NO") = crs("NO") prs("氏名") = crs("氏名") prs("連名") = crs("連名2") prs.Update t: crs.MoveNext Loop end sub