Case BUTTON_VERWIJDEREN
If rs.RecordCount <> 0 Then
[b]If there is [u]NO[/u] selected bookmarks (count less than or equal to 0) then set a form parameter.
Shows a new form and disabled the current one
[/b]
If grdDataGrid.SelBookmarks.Count <= 0 Then
gsFormParm = CMD_DELRCD & "|" & rs![OpdrachtId]
frmProductieOpdrachten.Show
Me.Enabled = False
Else
[b]
Note I don't understand holland speak so I may be missing something ;)
If you answer Yes, it creates an array of selected bookmarks.
(Assuming that the selected records in the dbGrid would be the bookmarks)
[/b]
If GeneralDialog(DIATYPE_OPERATORQ, Me.Caption, _
"Weet u zeker dat u de geselecteerde productieorders wilt verwijderen?", "") = _
DIABUTTON_YES Then
ReDim arrCurrentSelection(grdDataGrid.SelBookmarks.Count - 1)
lNumberCurrentlySelected = grdDataGrid.SelBookmarks.Count
For iCnt = 0 To grdDataGrid.SelBookmarks.Count - 1
arrCurrentSelection(iCnt) = grdDataGrid.SelBookmarks(iCnt)
Next iCnt
' definieer hoogste en de laagste selectie plus de selectiegrootte
lBeginSelect = DEF_MAXNBR_PRODUCTIEORDERS + 1
lEindeSelect = 0
[b]Looks like a loop through all array entries ...
Moves to the first bookmark (selected record)
Compares the start ID (currently max number of record +1)(see above) and either sets the beginning or End IDs
[/b]
For iCnt = LBound(arrCurrentSelection) To UBound(arrCurrentSelection)
rs.Bookmark = arrCurrentSelection(iCnt)
If rs![OpdrachtId] < lBeginSelect Then 'lager dan de vorige waarde?
lBeginSelect = rs![OpdrachtId]
End If
If rs![OpdrachtId] > lEindeSelect Then ' hoger dan de vorige
lEindeSelect = rs![OpdrachtId]
End If
Next iCnt
'OMM 6-10-2000; Gewijzigd om alleen de Orders te selecteren
Set rsSelect = gdbsMainDB.OpenRecordset( _
"SELECT * FROM ProductieOrders WHERE IsOrder = True ")
[b]Pull only records that the IsOrder has been set (has been ordered?)
For the beginning ID, find the first matching record.
While you still have records and the beginning ID is less than the end ID
Check if there is a product order charge.
Assume true = means there is one - then set the validated field of that record
False = Delete record - no charge made...
[/b]
rsSelect.FindFirst "OpdrachtId=" & lBeginSelect
Do While (Not rsSelect.EOF) _
And (lBeginSelect <= lEindeSelect)
'OMM 17-7-2000; Veranderd voor AS400 Koppeling
' alleen rsSelect.Delete bestond
If CheckProductieOrderHasCharge(rsSelect![bonnummer]) Then
rsSelect.Edit
rsSelect![IsVerwijderd] = True
rsSelect.Update
Else
rsSelect.Delete
End If
[b]move to the next record, adjust begining ID
[/b]
rsSelect.MoveNext
lBeginSelect = lBeginSelect + 1
Loop
[b]Possibly renumber records so they are consistant in incrementing numbers?[/b]
iSelectRegel = 1 ' New Id for the first Order
' Eerst renumber
rsSelect.MoveFirst
Do While Not rsSelect.EOF
rsSelect.Edit
rsSelect![OpdrachtId] = iSelectRegel
rsSelect.Update
rsSelect.MoveNext
iSelectRegel = iSelectRegel + 1
Loop
rsSelect.Close
datPrimaryRs.Refresh
End If
End If
End If