hatena
hatena
2024/08/01 (木) 11:45:18
下記のような感じになります。
'前略
Dim rs As DAO.Recordset, MainId As Long
Set rs = CurrentDb.OpenRecordset("T支給Main", dbOpenTable, dbAppendOnly)
rs.AddNew
rs!支給日付 = dt1 'dt1 はDate型
rs!支給先選択 = sikyusaki
rs!支給方法選択 = 1
rs!部材発送はまだ = -1
MainId = rs!メインID '生成されたメインID
rs.Update
rs.Close
Dim strSQL As String
strSQL = "INSERT INTO [T支給Sub] ([メインID], [部品ID], [支給数], [用意状況Memo]) " &
"SELECT " & MainId & " As [メインID], [材料支給ファイル対象ID], [注残の合計], [memo] " & _
"FROM [T部材発注accessからIN_直送分];"
CurrentDb.Execute strSQL, dbFailOnError
通報 ...