Click here to Skip to main content
16,016,760 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've created a a form called login which allows two users to log in but view different forms. Form 1 - allows you to view the database only. Form two allows the user to edit the Excel spreadsheet which I connected to the form (save, delete, add a record); but the code is not allowing the second user to view the second form.

VB
If txtUsername.Text = " " And txtPassword.Text = " " Then
            MsgBox("Please enter your username and Password.", MsgBoxStyle.Information, "Login")
        Else

            If txtUsername.Text = "" Then
                MsgBox("Please enter your Username", MsgBoxStyle.Information, "Login")
            Else

                If txtPassword.Text = "" Then
                    MsgBox("Please enter your Password", MsgBoxStyle.Information, "Login")
                Else

                    If txtUsername.Text = "admin" And txtPassword.Text = "admin0123" Then
                        Me.Hide()
                        Form2.Show() 'Form 2 is in view only format
                    Else
                        If txtUsername.Text = "stacey" And txtPassword.Text = "stacey01" Then
                            Me.Hide()
                            Form3.Show()



and my coding for the add, delete, save does not want to work at all.

Please help...
Posted
Updated 23-Nov-11 5:21am
v2
Comments
resonance_siv 23-Nov-11 8:38am    
wat add or delete... refine ur question
Hoeny-Plum 24-Nov-11 2:05am    
The "add", "save", and "delete" in talking about is on my form that i have created. Do i create seperate buttons that allow me to that or do encode it on the Load_form

1 solution

Try to debug your code line by line (F8) and you'll see why the Form2 is not accessible.
I suggest you to change code like this (it will be more readible for you):
VB
If txtUsername.Text = String.Empty Then
    MsgBox("Please enter your Username", MsgBoxStyle.Information, "Login")
    Exit Sub
End If
 
If txtPassword.Text = String.Empty Then
    MsgBox("Please enter your Password", MsgBoxStyle.Information, "Login")
    Exit Sub
End If

If txtUsername.Text = "admin" And txtPassword.Text = "admin0123" Then
    Me.Hide()
    Form2.Show() 'Form 2 is in view only format
End If

If txtUsername.Text = "stacey" And txtPassword.Text = "stacey01" Then
    Me.Hide()
    Form3.Show()
End If


Hint: Storing the names of users (logins) and passwords inside the program (inside the procedure) is not good practice.
 
Share this answer
 
v2
Comments
Hoeny-Plum 24-Nov-11 2:04am    
Thank you i'll be sure to try it. Would it be wise programming if i were to store the usernames ans passwords to a database.

Do i create buttons on my form to be able to "add", "save", and "delete" records on the database that i have connected to the form.
Kindly advise.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900