Module Code

Public id As Integer
Public names As String
Public role As String
Public rs As New ADODB.Recordset
Public con As New ADODB.Connection


Public Sub dbcon()
If con.State = adStateOpen Then con.Close
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\NC4\OOp\P4\library.mdb;Persist Security Info=False"
con.Open

End Sub


Public Sub rscon(q As String)
If rs.State = adStateOpen Then rs.Close
rs.CursorLocation = adUseClient
rs.Open q, con, adOpenDynamic, adLockOptimistic
End Sub


Private Sub cmdCon_Click()
Call dbcon

If lg(0).Text <> "" And lg(1).Text <> "" Then
log
    If rs.RecordCount > 0 Then
        role = rs.Fields("Role")
        id = rs.Fields("a.UserID")
         validate
            If rs.Fields("Validity") > Date Then
                getname
                names = rs.Fields("Fname")
                    If role = "administrator" Then
                    Call frmGuest.adminA
                    Unload Me
                    ElseIf role = "member" Then
               
                    Else
               
                    End If
           
   
            Else
                MsgBox "Upgrade first your account", vbOKOnly
            End If
    Else
        MsgBox "Incorrect Password and Username", vbOKOnly
    End If
Else
MsgBox "input a value", vbOKOnly

End If


End Sub

Public Sub log()
Dim a As String
a = "Select * from tblUserAccount a, tblRoles b where a.UserID = b.UserID and Uname like '" & lg(0).Text & "' and Password like '" & lg(1).Text & "'"
Call rscon(a)


End Sub

Public Sub validate()
Dim b As String
b = "Select * from tblMembership where UserID = " & id & " "
Call rscon(b)
End Sub

Public Sub getname()
Dim c As String
c = "Select Fname from tblUsers where UserID = " & id & ""
Call rscon(c)
End Sub

Private Sub Form_Load()
Call dbcon
End Sub

Post a Comment

0 Comments