Advertisement
Guest User

Untitled

a guest
Oct 11th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. DoCmd.OpenForm FormName:="Login", WindowMode:=acDialog
  2.  
  3. Dim Login As Form_Login
  4. Set Login = New Form_Login
  5. Login.Visible = True
  6.  
  7. DoCmd.OpenForm FormName:="Login", WindowMode:=acDialog
  8. Set Login = Forms("Login") 'Get instance of the Login form made invisible
  9. If Login.Success Then
  10. 'We've logged in; proceed
  11. Else
  12. 'We didn't connect; quit probably
  13. End If
  14.  
  15. Public Function MyConnection() As ADODB.Connection
  16. Static EnteredUserName As String
  17. Static EnteredPassword As String
  18.  
  19. Dim Login As Form_Login
  20.  
  21. Select Case True
  22. Case Len(EnteredUserName) = 0, _
  23. Len(EnteredPassword) = 0
  24. DoCmd.OpenForm FormName:="Login", WindowMode:=acDialog
  25. Set Login = Forms("Login")
  26. If Login.Success Then
  27. EnteredUserName = Login.UserName.Value
  28. EnteredPassword = Login.Password.Value
  29. Login.Password.Value = vbNullString
  30. InitializeDAOConnection(EnteredUserName, EnteredPassword)
  31. End If
  32. Set Login = Nothing
  33. DoCmd.Close acForm, "Login", acSaveNo
  34. End Select
  35.  
  36. Set MyConnection = New ADODB.Connection
  37. MyConnection.ConnectionString = MyConnectionString & _
  38. ConcatenateUserAndPassword(EnteredUserName, EnteredPassword)
  39. MyConnection.Open
  40. End Function
  41.  
  42. Public Enum DataAccessLibrarySupports
  43. SupportsDAO = 1
  44. SupportsADODB = 2
  45. End Enum
  46.  
  47. Public Event ConnectionLost()
  48.  
  49. Public Property Get ConnectionString() As String
  50. End Property
  51.  
  52. Public Property Let ConnectionString(NewValue As String)
  53. End Property
  54.  
  55. Public Function Connect( _
  56. UserName As String, _
  57. Password As String _
  58. ) As Boolean
  59. End Function
  60.  
  61. Public Function Connection( _
  62. DataAccessLibrary As DataAccessLibrarySupports _
  63. ) As Object
  64. End Function
  65.  
  66. Public Function Login( _
  67. UserName As String, _
  68. Password As String _
  69. ) As Boolean
  70. End Function
  71.  
  72. Public Function DbConnections() As IDbConnection
  73. End Function
  74.  
  75. Public Function DefaultDbConnection() As IDbConnection
  76. End Function
  77.  
  78. Public Function Quit() As Boolean
  79. End Function
  80.  
  81. Public Function Session() As ISession
  82. If IsLoaded("Splash") Then
  83. Set Session = Forms("Splash")
  84. Else
  85. 'This should never be the case; we likely got here
  86. 'because the developer mucked with stuff the wrong way.
  87. Err.Raise vbObjectError, "Session", "There is no session. Please ensure the form implementing ISession interface is opened and left open."
  88. End If
  89. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement