Solved

Restrict form Open failure

Posted on 2006-07-21
2
209 Views
Last Modified: 2010-05-18
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"
       Exit Sub
    End If
End Sub
0
Comment
Question by:billcute
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 38

Accepted Solution

by:
puppydogbuddy earned 250 total points
ID: 17158540
Bill,
move your code to the form open even and add a cancel statement.

Private Sub Form_Open(Cancel As Integer)
    If g_lAccessID > 3 And IsLoaded("Frm_Switchboard") Then
          MsgBox "You are not authorized to view this details", vbCritical + vbOKOnly, "No authorization"
          Cancel = True
          DoCmd.Close acForm, "frmMasterControlPanel"
       Exit Sub
    End If
End Sub
0
 
LVL 4

Author Comment

by:billcute
ID: 17159478
Thanks, it works.

Regards
Bill
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question