6

I have designed a data-entry Form for conducting a survey. For each survey question, only one answer can be selected from a list of multiple-choice answers. I have used an "Option group"(a set of radio buttons)Control for each set of multiple-choice answers such that each possible answer within the set has a radio button beside it which when clicked, would select that answer. Whenever the form is initially displayed(I'm not sure whether to say "opened" or "loaded") for use, I want each "Option group" to have none of its answers selected. I know the VBA code to use to achieve this. I wish to know the difference between the "On Load" event and the "On Open" event for any data-entry Form. After knowing the difference, I will know and understand which of these two events to apply the VBA code to.

1 Answer 1

15

Open

Open happens before Load and allows you to cancel so it doesn't open. It also allows access to OpenArgs. This can be helpful if your form requires user input. If it is not supplied, you can cancel the Form.Open or prompt the user for needed values.

Private Sub Form_Open(Cancel As Integer)
     If "" & OpenArgs = "" Then
         Cancel = True
         Msgbox "Open Arguments are required"
     End If 
End Sub

Load

Load happens after Open and lacks any of the control Open provides.

Private Sub Form_Load()
    Me.Caption = Date
End Sub

You may want to use both Events. Use Open to get the input parameters, and use Load to set the values of controls based on those supplied parameters.

References

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.