Solved

Restrict form Open failure

Posted on 2006-07-21
2
210 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

615 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