I have user form, which I used to show the status for an item. The items go through a 3-stage process. For each process there is a check box, which can be checked one the item has been through a stage. When clicked, the user is presented with an "Are you sure?" prompt. If the user selects "Yes" (vbYes) the process is marked as completed, in an SQL table.
The issue arises when I want to show items which has already been through one or more stages. When the form is initialized, I set the value of the check boxes for the relevant stages to "True". However, this activiates the click function of the check box, which is not intended. Is there a way to skip this?
Code example (not actualy code)
Private Sub UserForm_Initialize()
'Check check boxes, where stages are completed
If stage_1_completed Then
chkStage1.value = True
End If
If stage_2_completed Then
chkStage2.value = True
End If
If stage_3_completed Then
chkStage1.value = True
End If
End Sub
'This part should only run, if the check box is clicked manually
Private Sub chkStage1_Click()
If chkStage1.value = True Then
'Prompt user if sure?
promptAnswer = MsgBox("Are you sure?", vbYesNo, "Continue?")
'Mark stage 1 as processed if yes
If promptAnswer = vbYes Then
set_stage_completed (1)
End If
End If
End Sub
Aucun commentaire:
Enregistrer un commentaire