avoid using goto

paul j

Licensed User
As a reaction on some code I see. As in the help-example the goto can give unpredictable results. The code will be verry difficult to debug. Tip: don't use labels other then an errorlabel. Let the sub do just one single task, so you can call the entire sub in recursive.

Sub btnDCRecSave_Click
' pre het keyfield is uniek
' post waardes worden weggescheven in de geheugentabel

If KeyFieldUnique(date) = true Then
lvYesNo =Msgbox("date already exists. Delete existing record??")," ",cmsgboxYesNo,cMsgBoxQuestion)
If lvYesNo =cYes Then
smnuDCRecDelete_Click 'RecordDelete(aTable) <-- delete the record that has the same keyfield
gv_tbl_mutaties = true
gv_rec_Mutaties = false
btnDCRecSave_Click 'recursieve call <--- checks again the keyfield if it is unique
End If
End If
Last edited: