Learn how to a build a cloud-first strategyRegister Now


User Right Control in an App

Posted on 2005-05-09
Medium Priority
Last Modified: 2010-04-23
I have an App which has a MDI main form and several children. The children are opened
from the menu of the MDI form like this:

Case "Nbr Pool List"    ' ButtonTool
                ' Place code here
                Dim frm2 As New frmnbrAllocationList
                frm2.MdiParent = Me
                frm2.Text = "Nbr Pool List"

Now everytime someone opens a form i check what rights they have like below

URstring = (UserRights(gstrUserID, Me.Name))

        URread = Trim(URstring.Substring(0, 1))
        If URread = 0 Then
        End If

My problem now is that i want to prevent the user from opening the form if he does not have the rights ? So in case
URread = 0 i want to prevent the form from opening at all. Buty since i dispose the form the code which opens the
form in the menu complains once it gets to frm2.Show() since the form has been disposed. So is there a better
way to do this ? I want to avoid querying at the calling code since there is many places which could call a form and
it is easyer to manage it  when the form loads..

Also is there a way to check if a form has been disposed before i call the frm.show() that way i could
work arround my problem
Question by:AlexPonnath
  • 2

Expert Comment

ID: 13964057
The solution I think would be to have a common form open routine called from all the menu's (indeed anything that opens a form). So from your menu code you would call 'OpenForm "frmnbrAllocationList"', the routine would then first check access rights before opening the form.

Expert Comment

ID: 13966466
Agree with BadgerBill,

with regards your second point:

"Also is there a way to check if a form has been disposed before i call the frm.show() that way i could
work arround my problem"

You can check to see if the object is an instance before attempting to call any methods or functions on it, as follows:

If Not IsNothing(frmYourForm) Then
End If


Author Comment

ID: 13966854
But how does this work in an MDI enviorment where the user can open
multiple instances of the same form. How do i check if the correct instance
of the form has not been disposed.

Accepted Solution

doobdave earned 1500 total points
ID: 13979002
To clarify on my last post:
frmYourForm is the name of the INSTANCE of a form, rather than the actual form CLASS.

However, havnig looked at your post again, I now see it in a different light.

Is this code:
URstring = (UserRights(gstrUserID, Me.Name))

        URread = Trim(URstring.Substring(0, 1))
        If URread = 0 Then
        End If

in your "frmnbrAllocationList" class code?
If so, I suggest you do the rights checking in the code that creates the form, so that it only gets instantiated IF the rights are correct.


Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month20 days, 16 hours left to enroll

810 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