Restrict form Open failure
Posted on 2006-07-21
I currently placed the code below in the On Load Event of a form but when the form opens after a user "On Click event" in the Switchboard form and if the user's AccessID is greater than 3 then a msgbox tells user that he is "not authorized to view the form". To my display the form still opens immediately after the msgbox display.
Note that "g_lAccessID" uses a "Setup Global" in the standard module.
How do I rectify the code? such that the applicable form gives the user only the msgbox and then terminate without opening the target form.
Here is the code I am currently using
Private Sub Form_Load()
If g_lAccessID > 3 And IsLoaded("Frm_Switchboard") Then
MsgBox "You are not authorized to view this details", vbCritical + vbOKOnly, "No authorization"
DoCmd.Close acForm, "frmMasterControlPanel"