avoid using goto

Discussion in 'Code Samples & Tips' started by paul j, Nov 11, 2007.

  1. paul j

    paul j Member 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: Nov 11, 2007
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice