Login Form

Option Explicit

Dim Check As Integer

'******************************************************************

'******************************************************************

'** Subject : User Login Dialog Box

'** Date : Saturday, January, 03, 2004

'** Modified : Saturday, January, 03, 2004

'******************************************************************

'******************************************************************

Private Sub cmdOK_Click()

On Error GoTo ErHand

With Me

Set Conn = New ADODB.Connection

ConnectString = "Provider=SQLOLEDB.1;Password=" & .txtPassword & ";Persist Security Info=True;User ID=" & .TxtUser & ";Initial Catalog=" & .TxtDatabase & ";Data Source=" & .TxtServer & " "

Conn.Open ConnectString

ServerName = .TxtServer.Text

UserName = .TxtUser.Text

Password = .txtPassword.Text

Call SaveSetting(App.Title, "UserEntry", "UserName", .TxtUser)

Call SaveSetting(App.Title, "UserEntry", "ServerName", .TxtServer)

Call SaveSetting(App.Title, "UserEntry", "DatabaseName", .TxtDatabase.Text)

LoginSucceeded = True

Unload Me

MDIForm1.Show

End With

Exit Sub

ErHand:

MsgBox "Invalid Password, try again!", vbCritical, "Login"

txtPassword.SetFocus

SendKeys "{Home}+{End}"

End Sub

Private Sub Form_Load()

On Error GoTo ErrHandler:

With Me

.TxtUser = GetSetting(App.Title, "UserEntry", "UserName", "")

.TxtServer = GetSetting(App.Title, "UserEntry", "ServerName", "")

.TxtDatabase.AddItem GetSetting(App.Title, "UserEntry", "DatabaseName", "")

.TxtDatabase.Text = GetSetting(App.Title, "UserEntry", "DatabaseName", "")

ServerName = IIf(.TxtServer.Text = "", "Anoop", .TxtServer.Text)

UserName = IIf(.TxtUser.Text = "", "samee", .TxtUser.Text)

Password = IIf(.txtPassword.Text = "", "samee", .txtPassword.Text)

Screen.MousePointer = vbHourglass

Set Conn = New ADODB.Connection

ConnectString = "Provider=SQLOLEDB.1;Password=samee;Persist Security Info=True;User ID=samee;Initial Catalog=" & .TxtDatabase & ";Data Source=" & .TxtServer & " "

Conn.Open ConnectString

Call GetDatabaseList(TxtDatabase)

.TxtDatabase.AddItem GetSetting(App.Title, "UserEntry", "DatabaseName", "")

.TxtDatabase.AddItem "Master"

Screen.MousePointer = vbDefault

End With

Exit Sub

ErrHandler:

MsgBox "Server Name Not Found....." & vbCrLf & err.Description

err.Clear

If Screen.MousePointer = vbHourglass Then

Screen.MousePointer = vbDefault

End If

End Sub

Private Sub cmdCancel_Click()

LoginSucceeded = False

Me.Hide

End Sub