I have the following code, which is going through a FOR loop to run an INSERT statement with a nested SELECT statement. The issue is that I am trying to use the interator in the SQL statement, but the number never changes, even though the process is running through the proper number of times. What am I missing? Why is the number not appearing to be changing?
Code:
Sub SetLEAs()
Dim MyCnt As Integer
Dim i As Integer
MYSQL2 = "INSERT INTO DGBTestVariations2
(ID,
FeeSchedule,
LEA,
JURISDICTION,
PROSECUTOR)
SELECT ID,
FeeSchedule,
(SELECT LEA_Agency_Name
FROM LEA_NAMES
WHERE ID= " & MyCnt & ") ,
JURISDICTION,
PROSECUTOR
FROM DGBTestVariations
WHERE LEA='MuniPD';"
For MyCnt = 1 To 5
Application.SetOption "Confirm Action Queries", 0
DoCmd.RunSQL (MYSQL2)
Next MyCnt
Application.SetOption "Confirm Action Queries", 1
End Sub
Comment