Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Login Form Help

Status
Not open for further replies.

BBousman

Programmer
May 10, 2004
57
US
Okay, so I've searched through the forum and for the life of me I can't figure this out. I have two forms, a Login and a Main form. The Login form is the startup form and I set the program to close when the last form closes. What I'm looking for the program to do is you enter a username and password and it verifies it against the database and then closes or hides the Login form and loads the Main form. I have that much working but I have a Menubar with an option to Change Login under it. I've tried using Public variables to go between the forms to tell it to just load the settings for the user if the login is changed but that Public variable never goes back to the Login form to tell it that you want to change the login. Does anyone have a clue of how to do this?
 
In this scenario I would use a 'sub Main' as the applications entry point (this can be changed in the Project Properties), for example:

Code:
Module Main

   Public UName As String '<- Visible by all forms/classes/modules
   Public Mainfrm As Main '<- the main form

   'Application Entry Point
   Public Sub Main()
     
      Dim Loginfrm As New Login
      Dim Password As String
retry:
      If Loginfrm.ShowDialog = DialogResult.OK Then
         UName = Loginfrm.Username.Text
         Password = Loginfrm.Password.Text

         'Check db for Username Password
         If PasswordCorrect(UName, Password) Then

             Mainfrm = New Main
             Application.Run(Mainfrm)
         Else

             MsgBox("Incorrect Username or Password")
             GoTo retry

         End If
      End If
   End Sub
End Module
 
I tried that but the Sub Main never shows up as an option in the properties of the project. Is there something special I have to do in order for it to show up?
 
Nevermind, you have to uncheck that enable application framework checkbox.
 
Sort of. I have it so it will login fine but when I had a menu item with the option to change the logged in user, it wouldn't work. It either would close the whole program, wouldn't change the user name or would have open 2 main forms. Any clue of how to make it change the logged in user and get all their rights from the db if the main form is already open and you click on the menu item to change the logged in user?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top