Code 2
Code 2
Recordset Dim query As String query = "username = '" & txtUsername.Text & "'" query = query & " and password = '" & txtpassword.Text & "'" .Find (query) If .RecordCount > 0 Then MsgBox "Login Successful!" frmMenu.Show Unload Me Else MsgBox "Invalid username/password!", vbOKOnly + vbCritical, "Access denied!" txtUsername.Text = "" txtpassword.Text = "" txtUsername.SetFocus End If End With End Sub End Sub if text1.text = "username" and text2.text = "password" then msgbox "Welcome" form2.show Else: text1.text = "" and text2.text = "" then else msgbox "Error" End if
dim UsernameList(1000) as string dim PasswordList(1000) as string (Make sure you setup the arrays in this, maybe read them from a file) Username = Text1.text Password = Text1.text For Counter = 0 to ubound(UsernameList) If UsernameList = "" then counter = ubound(usernamelist) else if username = usernamelist(counter) then if password = passwordlist(counter) then msgbox "Logged in." form2.visible = true form1.visible = false else msgbox "incorrect password." endif else msgbox "nothing found" endif next counter 01 Private Sub cmdok_Click()
02 03 04 05 06 07 08 09 10 11 12 13 14 15 "Access 16 17 18 19 20 21 22
Static y As Integer Adodc1.Refresh With Adodc1.Recordset Dim query As String query = "username = '" & txtUsername.Text & "'" query = query & " and password = '" & txtpassword.Text & "'" .Find (query) If .RecordCount > 0 Then MsgBox "Login Successful!" frmMenu.Show Unload Me Else MsgBox "Invalid username/password!", vbOKOnly + vbCritical, denied!" txtUsername.Text = "" txtpassword.Text = "" txtUsername.SetFocus End If End With End Sub End Sub
If txtUsername1.Text = "admin" And txtPassword1.Text = "esther" Then MsgBox "Access Granted", vbInformation frmTrafficcontrol.Show frmPassword.Hide Else vntPass = MsgBox("Access Denied", vbAbortRetryIgnore + vbExclamation, "Wrong Ide ntity") End If