Hi.
I am working on creating a Log-On Screen that pops up when a button is pressed from another screen. I have to check when I am entering User Id and password if it is in the table (tblUSerID with fields : ID, UserName & Password). If UserID is found and password is correctly entered then Ok Button must be enabled. Can you give me some piece of codes that must be in my program to properly run. Thanks.
Option Explicit
Dim strsql As String
Private myConnection As New ADODB.Connection
Private UserRecordset As New ADODB.Recordset
Private connectStr As String
Private Sub cmdCancel_Click()
Unload frmLogon
End Sub
Private Sub Form_Load()
connectStr = "Provider = SQLOLEDB;" & _
"Data Source = Server1;" & _
"Initial Catalog = Ftracking_System;" & _
"Integrated Security = SSPI"
'strsql = "Select * from tblUserId"
strsql = "SELECT * FROM tblUserID where UserName = '" & txtUserName & "'"
If myConnection.state = 1 Then myConnection.Close
'BidConnection.Open connectStr
myConnection.Open connectStr
If myConnection.state = adStateOpen Then
UserRecordset.CursorType = adOpenKeyset
UserRecordset.LockType = adLockPessimistic
UserRecordset.Open strsql, myConnection
Else
MsgBox "The connection could not be made."
Debug.Print UserRecordset!UserName
End If
End Sub
Private Sub cmdOK_Click()
'FrmCalc.Show vbModal
Unload frmLogon
End Sub
Private Sub imgLogo_Click()
imgLogo.Picture = LoadPicture("face03.ico"
End Sub
Private Sub txtUserName_Change()
strsql = "Select * From tblUserId where UserName = '" & txtUserName & "'"
If UserRecordset.RecordCount > 0 Then
txtPassword.SetFocus
Exit Sub
Else
MsgBox "No User found"
End If
End Sub
I am working on creating a Log-On Screen that pops up when a button is pressed from another screen. I have to check when I am entering User Id and password if it is in the table (tblUSerID with fields : ID, UserName & Password). If UserID is found and password is correctly entered then Ok Button must be enabled. Can you give me some piece of codes that must be in my program to properly run. Thanks.
Option Explicit
Dim strsql As String
Private myConnection As New ADODB.Connection
Private UserRecordset As New ADODB.Recordset
Private connectStr As String
Private Sub cmdCancel_Click()
Unload frmLogon
End Sub
Private Sub Form_Load()
connectStr = "Provider = SQLOLEDB;" & _
"Data Source = Server1;" & _
"Initial Catalog = Ftracking_System;" & _
"Integrated Security = SSPI"
'strsql = "Select * from tblUserId"
strsql = "SELECT * FROM tblUserID where UserName = '" & txtUserName & "'"
If myConnection.state = 1 Then myConnection.Close
'BidConnection.Open connectStr
myConnection.Open connectStr
If myConnection.state = adStateOpen Then
UserRecordset.CursorType = adOpenKeyset
UserRecordset.LockType = adLockPessimistic
UserRecordset.Open strsql, myConnection
Else
MsgBox "The connection could not be made."
Debug.Print UserRecordset!UserName
End If
End Sub
Private Sub cmdOK_Click()
'FrmCalc.Show vbModal
Unload frmLogon
End Sub
Private Sub imgLogo_Click()
imgLogo.Picture = LoadPicture("face03.ico"
End Sub
Private Sub txtUserName_Change()
strsql = "Select * From tblUserId where UserName = '" & txtUserName & "'"
If UserRecordset.RecordCount > 0 Then
txtPassword.SetFocus
Exit Sub
Else
MsgBox "No User found"
End If
End Sub