I have some query about my code, I am using VB6.0 and I have a question using TimerControl… The user will first Login[frmLogin] and then the UserID and Password must recognize whether it is Admin or Guest. Once it was recognized as Admin, the user will be redirected to the frmAdmin and if not, he will be redirected to frmEmployee after the Timer[tmLogin]/Progressbar[pgLogin] reaches 100%. I’m just perplexed because I am using database with two tables[tblEmployee & tblPosition]. Each Table has an index: idxid for tblEmployee and idxpost for tblPosition… I don’t know where to insert the conditional statement… Please help me out, once it was resolved, it will be my rule for the further problem that I might encounter… Thanks in advance. Here is my code
Private Sub cmdContinue_Click()
Dim boolLogedIn As Boolean
If Me.txtUserID.Text = "" And Me.txtPassword.Text = "" Then
Me.lblWarning.Caption = "*User ID and Password must not be a null."
Me.tmLoginformSize.Enabled = True
Me.txtUserID.SetFocus
Beep
ElseIf Me.txtUserID.Text = "" Then
Me.lblWarning.Caption = "*User ID must not be a null."
Me.tmLoginformSize.Enabled = True
Me.txtUserID.SetFocus
Beep
ElseIf Me.txtPassword.Text = "" Then
Me.lblWarning.Caption = "*Password must not be a null."
Me.tmLoginformSize.Enabled = True
Me.txtPassword.SetFocus
Beep
Else
Do Until datLogin.Recordset.EOF
With datLogin.Recordset
If Me.txtUserID.Text = !empid And Me.txtPassword.Text = !Password Then
boolLogedIn = True
Exit Do
Else
datLogin.Recordset.MoveNext
End If
End With
Loop
If boolLogedIn = True Then
Me.tmLogin.Enabled = True
Me.lblConnecting.Visible = True
Me.lblLoginPercent.Visible = True
Me.pbLogin.Visible = True
Else
Me.lblWarning.Caption = "*User ID and Password did not match."
Me.datLogin.Recordset.MoveFirst
Me.tmLoginformSize.Enabled = True
Beep
End If
End If
End Sub
Private Sub tmLogin_Timer()
With Me.pbLogin
Me.pbLogin.Value = Me.pbLogin.Value + 1
Me.lblLoginPercent.Caption = Str(Me.pbLogin.Value) + "%"
If Me.pbLogin.Value >= 1 And Me.pbLogin.Value < 50 Then
Me.lblConnecting.Caption = "Connecting..."
ElseIf Me.pbLogin.Value >= 50 And Me.pbLogin.Value < 100 Then
Me.lblConnecting.Caption = "Logging in..."
Else
Me.lblConnecting.Caption = "Done..."
frmLogin.Hide
frmEmployee.Show
Me.tmLogin.Enabled = False
End If
End With
End Sub
…Here is my screenshots


Here is how I would accomplish what you are looking for with minimal changes to
your code :
You should take note of Rasel’s answer as well, since working directly with the connection and the recordset objects are preferable to the datacontrol.