MS Access: How do I Disable Form unless UserType is Admin

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mark Brodie
    New Member
    • Jan 2012
    • 1

    MS Access: How do I Disable Form unless UserType is Admin

    Hello,

    I'm new to here.

    My question is i have a table called tblLogin and it has Username and Password and Usertype in it Admin, Normal in usertype. How can i get when the user logs in as admin it shows cmsAdmin and if not admin they are normal it disables cmsAdmin this is the code i currently use for my login system.

    Code:
    Public Class frmLogin
        Dim vrfy As Boolean
    
        Private Sub frmLogin_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
            If vrfy = False Then
                End
            End If
        End Sub
    
        Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click
    
            Call IsConnected("Select * from tblAdmin where Username='" & Me.TextBox1.Text & "' and Password='" & Me.TextBox2.Text & "'", False)
    
            If MyDr.Read = True Then
                frmMain.Show()
                frmMain.cmdLogout.Text = "Logout"
            Else
                MsgBox("Access Denied!", MsgBoxStyle.Critical, "Error")
                Call IsConnected("Insert into tblLog values('" & _
                    Me.TextBox1.Text & "','" & _
                    Me.txtDate.Text & "','" & _
                    Me.txtTime.Text & "')", True)
            End If
    
            TextBox1.Text = ""
            TextBox2.Text = ""
            TextBox1.Focus()
    
        End Sub
    
      
        Private Sub cmdClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClose.Click
            Me.Close()
        End Sub
    
        Private Sub frmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            txtDate.Text = Now.ToString("dd/MM/yyy")
            txtTime.Text = Now.ToString("hh:mm:ss tt")
        End Sub
    End Class
    Last edited by NeoPa; Jan 20 '12, 12:40 AM. Reason: Added mandatory [CODE] tags for you
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32653

    #2
    This is a VB.NET question and doesn't ask anything Access specific so I'll move it across for you to the relevant forum.

    I expect the experts there will want some more basic information about what objects you're working with before they can be much help, but I'll leave that to you and they to sort out.

    Comment

    Working...