Controling button enabling using another form

ABOU

Member
Joined
Apr 29, 2008
Messages
14
Programming Experience
Beginner
As part of my program i wish to prevent a user deleting any records unless the username supplied at the logon screen is equal to "Admin"

I have been using the code

VB.NET:
'Check if User name = Admin if so enable the delete button
        If frmPass.txtPass.Text = "Admin" Then
            Me.btnDel.Enabled = True
        Else
            frmClient.btnDel.Enabled = False
        End If

In the form load event of the client form. When the password form is before the client form the code enables the button, but i have created a menu which the password form loads to. Now when the client form loads the button is left disabled.

Why is this and how do i fix it?
 
I guess that you have a login form which you retrieve the password from. Then you made another control that allows the user to type in a password and you want this password too to be used when setting the enabled property of the button?

If that is so, you must centralize the data. That is, when the login form closes, you must take the password and set it to a certain variable. Then, when the login button is clicked on the other form, you must set that same variable to the new value. Then, whenever the variable changes, you call the code you have to set button enabled or disabled depending on the value of the variable. Not the text on either textboxes.

I must say I'm not sure I understand the problem correctly...
 
Back
Top