jwd389 0 Newbie Poster

I have a program which which enables staff to sign in to the application by checking their username and password in the database, to verify their log in.

I have added a field job description in the staff table, and would like to disable buttons on the main menu depending on the job description of the user.

E.g if manager signs in then all buttons enabled or Sales Assistant signs in then some button disabled.

Below is the code I currently have for the log in form, but am not sure how to adjust the SQL or coding to suit user permissions.

Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        Dim connection As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\College\HND Year Two\Project Development\Milestone 6\Staff.accdb;User Id=admin;Password=;")


        Dim instruction As OleDbCommand = New OleDbCommand( _
                        "SELECT * FROM Staff WHERE Username = '" & _txtUsername.Text & "' AND Password = '" & txtPassword.Text & "' ", connection)
        connection.Open()
        Dim dataread As OleDbDataReader = instruction.ExecuteReader()

        If (dataread.Read() = True) Then
            Hide()
            MainMenu.Show()
            txtUsername.Clear()
            txtPassword.Clear()
        Else : MessageBox.Show("Error Incorrect Username or password, Try again")

        End If

    End Sub

Any help is greatly appreciated

Thanks JWD

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.