Dim strSQL As String
Dim iOpl As Integer
Dim dtStart As Date, dtEind As Date
Dim iStart As Long, iEind As Long
Dim iRegNum() As Variant
Dim i As Integer, iAantal As Integer, x As Integer
Dim tmp
iOpl = Me.Keuzelijst_beschikbare_opleidingen.Value
dtStart = Me.StartdatumINVOER
dtEind = Me.EinddatumINVOER
iStart = CLng(dtStart)
iEind = CLng(dtEind)
strSQL = "SELECT Rijksregisternummer FROM [WN_Persoonsgegevens] WHERE [Tijdelijke selectie]=True"
With CurrentDb.OpenRecordset(strSQL)
If .RecordCount > 0 Then
.MoveFirst
.MoveLast
iAantal = .RecordCount
.MoveFirst
ReDim iRegNum(iAantal)
Do While Not .EOF
i = i + 1
iRegNum(i) = .Fields("Rijksregisternummer").Value
.MoveNext
Loop
End If
.Close
End With
If i > 0 Then
For x = LBound(iRegNum) To UBound(iRegNum)
strSQL = "SELECT [Rijksregisternummer], [Opleiding Id], Startdatum, Einddatum, [Attest ok] " _
& "FROM [WN_Opleidingen(gevolgd)]" & vbCrLf
strSQL = strSQL & "WHERE [Rijksregisternummer]=" & iRegNum(x) & " AND [Opleiding Id]=" & iOpl
With CurrentDb.OpenRecordset(strSQL)
If .RecordCount = 0 Then
.AddNew
.Fields("Rijksregisternummer") = iRegNum(x)
.Fields("[Opleiding Id]") = iOpl
.Fields("Startdatum") = CDate(iStart)
.Fields("Einddatum") = CDate(iEind)
.Fields("[Attest ok]") = True
.Update
End If
End With
Next x
End If