Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DoCmd.OpenForm FormName:="Login", WindowMode:=acDialog
- Dim Login As Form_Login
- Set Login = New Form_Login
- Login.Visible = True
- DoCmd.OpenForm FormName:="Login", WindowMode:=acDialog
- Set Login = Forms("Login") 'Get instance of the Login form made invisible
- If Login.Success Then
- 'We've logged in; proceed
- Else
- 'We didn't connect; quit probably
- End If
- Public Function MyConnection() As ADODB.Connection
- Static EnteredUserName As String
- Static EnteredPassword As String
- Dim Login As Form_Login
- Select Case True
- Case Len(EnteredUserName) = 0, _
- Len(EnteredPassword) = 0
- DoCmd.OpenForm FormName:="Login", WindowMode:=acDialog
- Set Login = Forms("Login")
- If Login.Success Then
- EnteredUserName = Login.UserName.Value
- EnteredPassword = Login.Password.Value
- Login.Password.Value = vbNullString
- InitializeDAOConnection(EnteredUserName, EnteredPassword)
- End If
- Set Login = Nothing
- DoCmd.Close acForm, "Login", acSaveNo
- End Select
- Set MyConnection = New ADODB.Connection
- MyConnection.ConnectionString = MyConnectionString & _
- ConcatenateUserAndPassword(EnteredUserName, EnteredPassword)
- MyConnection.Open
- End Function
- Public Enum DataAccessLibrarySupports
- SupportsDAO = 1
- SupportsADODB = 2
- End Enum
- Public Event ConnectionLost()
- Public Property Get ConnectionString() As String
- End Property
- Public Property Let ConnectionString(NewValue As String)
- End Property
- Public Function Connect( _
- UserName As String, _
- Password As String _
- ) As Boolean
- End Function
- Public Function Connection( _
- DataAccessLibrary As DataAccessLibrarySupports _
- ) As Object
- End Function
- Public Function Login( _
- UserName As String, _
- Password As String _
- ) As Boolean
- End Function
- Public Function DbConnections() As IDbConnection
- End Function
- Public Function DefaultDbConnection() As IDbConnection
- End Function
- Public Function Quit() As Boolean
- End Function
- Public Function Session() As ISession
- If IsLoaded("Splash") Then
- Set Session = Forms("Splash")
- Else
- 'This should never be the case; we likely got here
- 'because the developer mucked with stuff the wrong way.
- Err.Raise vbObjectError, "Session", "There is no session. Please ensure the form implementing ISession interface is opened and left open."
- End If
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement