'frmLogin
Option Explicit
Private mReturn As VbMsgBoxResult
Private mConnectionString As String
Private mUserName As String
Private mPassword As String
Private mConnection As ADODB.Connection
Public Property Get ConnectionString() As String
ConnectionString = mConnectionString
End Property
Public Property Let ConnectionString(vData As String)
mConnectionString = vData
End Property
Public Property Get UserName() As String
UserName = mUserName
End Property
Public Property Let UserName(vData As String)
mUserName = vData
End Property
Public Property Get Password() As String
Password = mPassword
End Property
Public Property Let Password(vData As String)
mPassword = vData
End Property
Public Property Get Connection() As ADODB.Connection
Set Connection = mConnection
End Property
Public Function ShowLogIn(ConnectionString As String, Optional UserName As String, Optional Password As String, Optional OwnerForm As Variant) As VbMsgBoxResult
mConnectionString = ConnectionString
mUserName = UserName
mPassword = Password
Show vbModal, OwnerForm
ShowLogIn = mReturn
End Function
Private Sub cmdCancel_Click()
mReturn = vbCancel
Unload Me
End Sub
Private Sub cmdOK_Click()
On Error GoTo cmdOK_Click_Err
Set mConnection = LogIn(ConnectionString, txtUserName, txtPassword)
mUserName = txtUserName
mPassword = txtPassword
mReturn = vbOK
cmdOK_Click_Exit:
Exit Sub
cmdOK_Click_Err:
MsgBox Err.Description, vbCritical, Err.Source
Resume cmdOK_Click_Exit
End Sub
Private Sub Form_Load()
txtUserName = mUserName
txtPassword = mPassword
End Sub