Advertisement
Guest User

Untitled

a guest
Feb 24th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Dim bCanSafleyClose As Boolean
  5.  
  6.  
  7. Private Sub btnLogin_Click()
  8. Dim rst As Recordset
  9.  
  10. Set rst = CurrentDb.OpenRecordset("SELECT * From tblUsers WHERE UserName = '" & txtUsername & "' AND Password = '" & txtPassword & "' AND UserType ='" & cmbxUserType & "';")
  11.  
  12. If rst.RecordCount = 1 Then
  13. bCanSafleyClose = True
  14. DoCmd.Close
  15. DoCmd.OpenForm "Main"
  16.  
  17. Else
  18. MsgBox "Error!"
  19. bCanSafleyClose = False
  20.  
  21. End If
  22.  
  23. End Sub
  24.  
  25. Private Sub Form_Load()
  26. bCanSafleyClose = False
  27. End Sub
  28.  
  29. Private Sub Form_Unload(Cancel As Integer)
  30. 'Cancel = Not bCanSafleyClose
  31. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement