0

hello sir..i already put the word "Username" in my textbox thank you for this sir...regarding to the remember me sir it always rememeber to the one user account...is this possible sir it can remember also to other user if they click the remember me..example first user.. username=Jenny password=*****.so if the user click the remember me..then after that the user will exit so the rememeber me is already check so when it compile again this will display to the textbox with the username=jenny and password=***.but if the user unclick this and change the username=michael password=*** and click again so that this new user name will be remember if he exit and compile again the program..so username= michael will now be display to the texbox with corressponding password... please help me on this sir...here is my code...hoping for your positive responds...thank you in advance sir...

Option Explicit

Public con As ADODB.Connection
Private user_rs As ADODB.Recordset
Public cmd As ADODB.Command
Private m_user As String
Private m_pass As String
Private sql As String
Private attempts As Integer
Private WithEvents remember_rs As ADODB.Recordset
Private login_rs As ADODB.Recordset


Private Sub Form_Load()

Set con = New ADODB.Connection
Set user_rs = New ADODB.Recordset
Set remember_rs = New ADODB.Recordset
Set cmd = New ADODB.Command
Set login_rs = New ADODB.Recordset


con.Open "provider = microsoft.jet.oledb.4.0; data source = " & App.Path & "\password.mdb;persist security info =false; jet oledb:database password=eldenz;"

user_rs.Open "select user_name,user_pass,rememberYesNo from security ", con, adOpenStatic, adLockOptimistic

If user_rs.BOF = True Or user_rs.EOF = True Then
   MsgBox "not register yet"
   Exit Sub
 Else
 
 If Not user_rs!rememberYesNo = "No" Then
   
    txtuser.Text = user_rs!user_name
    txtpass.Text = user_rs!user_pass
    txtpass.PasswordChar = "*"
    chkbox.Value = 1
    End If
End If
Me.Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
attempts = 0
user_rs.Close
End Sub



Private Sub cmdlog_Click()


 m_user = Trim(txtuser.Text)
 m_pass = Trim(txtpass.Text)



Set user_rs = New ADODB.Recordset

sql = "select COUNT (user_name) AS JEMEBE FROM SECURITY where user_name = '" & m_user & "' and user_pass ='" & m_pass & "'"
user_rs.Open sql, con, adOpenDynamic, adLockOptimistic


If user_rs.Fields("JEMEBE") = 0 Then
 
   attempts = attempts + 1
    
   MsgBox "Maybe You have Incorrect Username and Password", vbExclamation, "Please sign-up to register account"
  
   lblattempt.Caption = attempts
  If attempts = 1 Then
     MsgBox "you have 2 attempt left"
    
  ElseIf attempts = 2 Then
     MsgBox "You have 1 attempt remaining,this is your last chance."
    
  End If
  
  If attempts = 3 Then
      txtuser.Enabled = False
      txtpass.Enabled = False
      MsgBox "You have already consume your 3 attempts...try again tomorrow.!!"
      
   End If
  Exit Sub
  
 
Else
 
   Unload Me
   Form6.Show
   user_rs.Close
  
   End If
   
   
End Sub
Private Sub cmdexit_Click()
Unload Me
End Sub


Private Sub lblremember_Click()
 
  If chkbox.Value = 0 Then
    chkbox.Value = 1
    Else
     chkbox.Value = 0
     End If
     
     
    Set user_rs = New ADODB.Recordset

user_rs.Open "select * from security ", con, adOpenStatic, adLockOptimistic


  If user_rs.BOF = True Or user_rs.EOF = True Then
    
       If chkbox.Value = 0 Then
              chkbox.Value = 1
         Else
           chkbox.Value = 0
         End If
   Else
    
           If user_rs!rememberYesNo = "No" Then
              user_rs!rememberYesNo = "Yes"
              user_rs.Update
             Else
               user_rs!rememberYesNo = "No"
               user_rs.Update
            
             End If
             
          
           
           
      End If
      
      
End Sub

Private Sub lblsign_Click()
Form16.Show
Unload Me
End Sub


Private Sub txtpass_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
  cmdlog_Click
  Else
    If txtpass.Text = "Password" Then
       txtpass.Text = ""
       txtpass.PasswordChar = "*"
     End If
 End If
End Sub

Private Sub txtuser_KeyPress(KeyAscii As Integer)

 If txtuser.Text = "Username" Then
  txtuser.Text = ""
  End If
End Sub
0

Yes you can let different users log on with the remember me option. All you need to do is to search the database AFTER the user entered his/her username to check if they are to be remembered. The quickest way to probably do this is to let a user select their username from a combobox, loaded with all the users in the security database. Once they have selected their username, check the remember me criteria, and let them login accordingly.

You will need a statement in your search as -

Rs.Open "SELECT username, password, rememberyesno FROM Security WHERE username = " & "'" & cmbUsername.Text & "'"

Do some error trapping as well as in -

If Rs.EOF 'etc etc.

Just remember with the above, you are making your application vulnerable because if any user selects someone that can be logged in automatically, they will have access to your application. I have written my applications where the security database is on the users pc. and the rest of my data on a server. Only one user per pc is allowed to login, but this is a discussion for a some other time.

Edited by AndreRet: Added comment

0

sir thank you for the reply..where i am going to insert that code sir in the remember me label sir? so i am going to change my textbox to combobox sir?hoping for your positive responds....

Edited by jemz: n/a

0

Hi Jemz.

Ok, first of all, read my last part about the security of your application when you have users selecting from a list. Rather have your security database installed on each USER machine, where only that 1 user log in to. If your database is running from the same pc as well, seperate your security database from the actual database. This way you have only one record in the security database with only one user logging in. Once you have more than one record, say jemz with the option to be logged in automatically, and andre at record two with no option, andre (or anybody else ofr that matter) can select jemz and click on 'GO' and be logged in to your database WITHOUT the proper credentials or authority.

With the above said, you do not need to replace your txtUsername at all. Just add a combobox with the following code -

'Under your general declarations add the following

Private WithEvents rsLoadNames As ADODB.Recordset

'Create a new sub as below
Private Sub LoadNames()

Set rsLoadNames = New ADODB.Recordset

rsLoadNames.Open "SELECT UserName FROM LoginData", cnLogin, adOpenStatic, adLockOptimistic

If rsLoadNames.EOF = True Or rsLoadNames.BOF = True Then
    
    Exit Sub
        Else
    Do While rsLoadNames.EOF = False
        cmbLoadNames.AddItem rsLoadNames("Username")
        rsLoadNames.MoveNext
    Loop

cmbLoadNames.Text = "Select a Username from the list"
End Sub

'Under your form load event call the load name sub. You will need to remove the code checking for a login status. That code will be used under your cmbLoadnames click event.

Call LoadNames 'Your combobox will now be filled with all the Usernames in the database.

'Under the combobox click event add the following -

If cmbLoadnames.Text = "" Or cmbLoadnames.Text = "Select a Username from the list" Then
   Msgbox "No Username selected." '......... etc
   Exit Sub
      Else
   Set rsLogin = New ADODB.Recordset
'This is where you will add your search clause of WHERE NAME = to something...
   rsLogin.Open "SELECT UserName, Password, RememberMeYesNo  FROM LoginData WHERE UserName = " & "'" & cmbLoadnames.text & "'", cnLogin, adOpenStatic, adLockOptimistic

txtUsername.Text = rsLogin!UserName
'Now use the part from your form load event to check if the user is to be remembered or not.
0

hello sir thank you for the reply i will write again if i have doubt in my code, okey sir i will add combobox...more power to you sir...thank you for helping me...

Edited by jemz: n/a

0

Hi Jemz.

Ok, first of all, read my last part about the security of your application when you have users selecting from a list. Rather have your security database installed on each USER machine, where only that 1 user log in to. If your database is running from the same pc as well, seperate your security database from the actual database. This way you have only one record in the security database with only one user logging in. Once you have more than one record, say jemz with the option to be logged in automatically, and andre at record two with no option, andre (or anybody else ofr that matter) can select jemz and click on 'GO' and be logged in to your database WITHOUT the proper credentials or authority.

With the above said, you do not need to replace your txtUsername at all. Just add a combobox with the following code -

'Under your general declarations add the following

Private WithEvents rsLoadNames As ADODB.Recordset

'Create a new sub as below
Private Sub LoadNames()

Set rsLoadNames = New ADODB.Recordset

rsLoadNames.Open "SELECT UserName FROM LoginData", cnLogin, adOpenStatic, adLockOptimistic

If rsLoadNames.EOF = True Or rsLoadNames.BOF = True Then
    
    Exit Sub
        Else
    Do While rsLoadNames.EOF = False
        cmbLoadNames.AddItem rsLoadNames("Username")
        rsLoadNames.MoveNext
    Loop

cmbLoadNames.Text = "Select a Username from the list"
End Sub

'Under your form load event call the load name sub. You will need to remove the code checking for a login status. That code will be used under your cmbLoadnames click event.

Call LoadNames 'Your combobox will now be filled with all the Usernames in the database.

'Under the combobox click event add the following -

If cmbLoadnames.Text = "" Or cmbLoadnames.Text = "Select a Username from the list" Then
   Msgbox "No Username selected." '......... etc
   Exit Sub
      Else
   Set rsLogin = New ADODB.Recordset
'This is where you will add your search clause of WHERE NAME = to something...
   rsLogin.Open "SELECT UserName, Password, RememberMeYesNo  FROM LoginData WHERE UserName = " & "'" & cmbLoadnames.text & "'", cnLogin, adOpenStatic, adLockOptimistic

txtUsername.Text = rsLogin!UserName
'Now use the part from your form load event to check if the user is to be remembered or not.

hello sir is it possible not to use combobox?...sir i will just separate the database of my remember me sir..like you said...i will write again sir..thank you in advance....hoping for your positive responds...

0

Hi Jemz.

Ok, first of all, read my last part about the security of your application when you have users selecting from a list. Rather have your security database installed on each USER machine, where only that 1 user log in to. If your database is running from the same pc as well, seperate your security database from the actual database. This way you have only one record in the security database with only one user logging in. Once you have more than one record, say jemz with the option to be logged in automatically, and andre at record two with no option, andre (or anybody else ofr that matter) can select jemz and click on 'GO' and be logged in to your database WITHOUT the proper credentials or authority.

With the above said, you do not need to replace your txtUsername at all. Just add a combobox with the following code -

'Under your general declarations add the following

Private WithEvents rsLoadNames As ADODB.Recordset

'Create a new sub as below
Private Sub LoadNames()

Set rsLoadNames = New ADODB.Recordset

rsLoadNames.Open "SELECT UserName FROM LoginData", cnLogin, adOpenStatic, adLockOptimistic

If rsLoadNames.EOF = True Or rsLoadNames.BOF = True Then
    
    Exit Sub
        Else
    Do While rsLoadNames.EOF = False
        cmbLoadNames.AddItem rsLoadNames("Username")
        rsLoadNames.MoveNext
    Loop

cmbLoadNames.Text = "Select a Username from the list"
End Sub

'Under your form load event call the load name sub. You will need to remove the code checking for a login status. That code will be used under your cmbLoadnames click event.

Call LoadNames 'Your combobox will now be filled with all the Usernames in the database.

'Under the combobox click event add the following -

If cmbLoadnames.Text = "" Or cmbLoadnames.Text = "Select a Username from the list" Then
   Msgbox "No Username selected." '......... etc
   Exit Sub
      Else
   Set rsLogin = New ADODB.Recordset
'This is where you will add your search clause of WHERE NAME = to something...
   rsLogin.Open "SELECT UserName, Password, RememberMeYesNo  FROM LoginData WHERE UserName = " & "'" & cmbLoadnames.text & "'", cnLogin, adOpenStatic, adLockOptimistic

txtUsername.Text = rsLogin!UserName
'Now use the part from your form load event to check if the user is to be remembered or not.

hello sir gudafternoon...sir i have question do i still need the label remember me or to remove this label because i put combobox...hoping for your positive responds...thank you in advance....

0

If you have a combobox to choose a username from, I would rather remove the "Remember Me" option completely. This will enhance your security options. In other words, a user can select his username from the combo box, but they will still be forced to enter a password to login.

I hope this helps.

0

Hi Jemz.

Ok, first of all, read my last part about the security of your application when you have users selecting from a list. Rather have your security database installed on each USER machine, where only that 1 user log in to. If your database is running from the same pc as well, seperate your security database from the actual database. This way you have only one record in the security database with only one user logging in. Once you have more than one record, say jemz with the option to be logged in automatically, and andre at record two with no option, andre (or anybody else ofr that matter) can select jemz and click on 'GO' and be logged in to your database WITHOUT the proper credentials or authority.

With the above said, you do not need to replace your txtUsername at all. Just add a combobox with the following code -

'Under your general declarations add the following

Private WithEvents rsLoadNames As ADODB.Recordset

'Create a new sub as below
Private Sub LoadNames()

Set rsLoadNames = New ADODB.Recordset

rsLoadNames.Open "SELECT UserName FROM LoginData", cnLogin, adOpenStatic, adLockOptimistic

If rsLoadNames.EOF = True Or rsLoadNames.BOF = True Then

    Exit Sub
        Else
    Do While rsLoadNames.EOF = False
        cmbLoadNames.AddItem rsLoadNames("Username")
        rsLoadNames.MoveNext
    Loop

cmbLoadNames.Text = "Select a Username from the list"
End Sub

'Under your form load event call the load name sub. You will need to remove the code checking for a login status. That code will be used under your cmbLoadnames click event.

Call LoadNames 'Your combobox will now be filled with all the Usernames in the database.

'Under the combobox click event add the following -

If cmbLoadnames.Text = "" Or cmbLoadnames.Text = "Select a Username from the list" Then
   Msgbox "No Username selected." '......... etc
   Exit Sub
      Else
   Set rsLogin = New ADODB.Recordset
'This is where you will add your search clause of WHERE NAME = to something...
   rsLogin.Open "SELECT UserName, Password, RememberMeYesNo  FROM LoginData WHERE UserName = " & "'" & cmbLoadnames.text & "'", cnLogin, adOpenStatic, adLockOptimistic

txtUsername.Text = rsLogin!UserName
'Now use the part from your form load event to check if the user is to be remembered or not.

end quote.

hello sir,but sir i did not remove the label remember me..i have 2 table sir when the user click the remember me this will add to my table logIn...it works sir but please correct me if i am wrong..but before you look to my code i have question regarding in your withevents for what is that sir?...also sir,can you look at this if login_rs.state=adstateopen then login_rs.close end if.. why is that if will not use that it always object is open or object is close...here is my code sir correct me if i am wrong..hoping for your positive responds..

Option Explicit

Public con As ADODB.Connection
Private user_rs As ADODB.Recordset
Public cmd As ADODB.Command
Public m_user As String
Public m_pass As String
Public sql As String
Public attempts As Integer
Public login_rs As ADODB.Recordset

Private Sub Form_Load()

Set con = New ADODB.Connection
Set user_rs = New ADODB.Recordset
Set cmd = New ADODB.Command
Set login_rs = New ADODB.Recordset


con.Open "provider = microsoft.jet.oledb.4.0; data source = " & App.Path & "\password.mdb;persist security info =false; jet oledb:database password=eldenz;"

Call loadname

 If login_rs.State = adStateOpen Then
   login_rs.Close
   End If



  sql = "select log_name,log_pass, rememberYesNo from logIn where rememberYesNo = 'Yes' "
  login_rs.Open sql, con, adOpenDynamic, adLockOptimistic

  If login_rs.BOF = True Or login_rs.EOF = True Then
   Else

     If Not login_rs!rememberYesNo = "No" Then
       txtuser.Text = login_rs!log_name
       txtpass.Text = login_rs!log_pass
       txtpass.PasswordChar = "*"
       chkbox.Value = 1


      End If

  End If


Me.Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
attempts = 0

End Sub


Private Sub cboloadnames_Click()

If cboloadnames.Text = "" Or cboloadnames.Text = "Select a Username from the list" Then
   MsgBox "No Username selected."
   Exit Sub

 Else
  Set login_rs = New ADODB.Recordset

   login_rs.Open "select log_name,log_pass,rememberYesNo from logIn where log_name = '" & cboloadnames.Text & "' ", con, adOpenDynamic, adLockPessimistic

   txtuser.Text = login_rs!log_name

     If login_rs.BOF = True And login_rs.EOF = True Then

      Else

         If Not login_rs!rememberYesNo = "No" Then
          txtuser.Text = login_rs!log_name
          txtpass.Text = login_rs!log_pass
          txtpass.PasswordChar = "*"
          chkbox.Value = 1
     End If
  End If
End If

End Sub

Private Sub cmdlog_Click()

 m_user = Trim(txtuser.Text)
 m_pass = Trim(txtpass.Text)

Set user_rs = New ADODB.Recordset

 sql = "select COUNT (user_name) AS JEMEBE FROM SECURITY where user_name = '" & m_user & "' and user_pass ='" & m_pass & "'"
 user_rs.Open sql, con, adOpenDynamic, adLockOptimistic


If user_rs.Fields("JEMEBE") = 0 Then

   attempts = attempts + 1
   MsgBox "Maybe You have Incorrect Username and Password", vbExclamation, "Please sign-up to register account"
   lblattempt.Caption = attempts

  If attempts = 1 Then
     MsgBox "you have 2 attempt left"

     ElseIf attempts = 2 Then
    MsgBox "You have 1 attempt remaining,this is your last chance."
   End If

  If attempts = 3 Then
      txtuser.Enabled = False
      txtpass.Enabled = False
      MsgBox "You have already consume your 3 attempts...try again tomorrow.!!"
    End If
   Exit Sub

  Else
   Unload Me
   Form6.Show
   user_rs.Close
  End If


End Sub
Private Sub cmdexit_Click()
Unload Me
End Sub


Private Sub loadname()

Set login_rs = New ADODB.Recordset
login_rs.Open "select log_name from logIn  ", con, adOpenDynamic, adLockOptimistic

If login_rs.BOF = True And login_rs.EOF = True Then
  Else
    Do While login_rs.EOF = False
       cboloadnames.AddItem login_rs("log_name")
       login_rs.MoveNext
      Loop

      cboloadnames.Text = "select user name"
      End If
End Sub
Private Sub lblremember_Click()

 If chkbox.Value = 0 Then
     chkbox.Value = 1
    Else
    chkbox.Value = 0
   End If


 If txtuser.Text = "Username" Then
      MsgBox "Please put Username to continue", vbExclamation, "Username"
      chkbox.Value = 0
      txtuser.SetFocus
      Exit Sub
      End If

 m_user = Trim(txtuser.Text)




If login_rs.State = adStateOpen Then
  login_rs.Close
 End If

sql = "select log_name,log_pass,rememberYesNo from logIn where log_name = '" & m_user & "'"
login_rs.Open sql, con, adOpenDynamic, adLockOptimistic


If login_rs.BOF = True And login_rs.EOF = True Then

       If chkbox.Value = 0 Then
            chkbox.Value = 1
            Else
            chkbox.Value = 0
           End If

            With login_rs
            .AddNew
            !log_name = Trim(txtuser.Text)
            !log_pass = Trim(txtpass.Text)
            .Update
            .Close
             End With
         Else



                If login_rs!rememberYesNo = "No" Then
                     login_rs!rememberYesNo = "Yes"
                     login_rs.Update

                     Else

                    login_rs!rememberYesNo = "No"
                    login_rs.Update

                End If

 End If

End Sub

Private Sub lblsign_Click()
Form16.Show
Unload Me
End Sub


Private Sub txtpass_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
  cmdlog_Click
  Else
    If txtpass.Text = "Password" Then
       txtpass.Text = ""
       txtpass.PasswordChar = "*"
     End If
 End If
End Sub

Private Sub txtuser_KeyPress(KeyAscii As Integer)

 If txtuser.Text = "Username" Then
  txtuser.Text = ""
  End If
End Sub

Edited by mike_2000_17: Fixed formatting

0

Hi Jemz.

Ok, first of all, read my last part about the security of your application when you have users selecting from a list. Rather have your security database installed on each USER machine, where only that 1 user log in to. If your database is running from the same pc as well, seperate your security database from the actual database. This way you have only one record in the security database with only one user logging in. Once you have more than one record, say jemz with the option to be logged in automatically, and andre at record two with no option, andre (or anybody else ofr that matter) can select jemz and click on 'GO' and be logged in to your database WITHOUT the proper credentials or authority.

With the above said, you do not need to replace your txtUsername at all. Just add a combobox with the following code -

'Under your general declarations add the following

Private WithEvents rsLoadNames As ADODB.Recordset

'Create a new sub as below
Private Sub LoadNames()

Set rsLoadNames = New ADODB.Recordset

rsLoadNames.Open "SELECT UserName FROM LoginData", cnLogin, adOpenStatic, adLockOptimistic

If rsLoadNames.EOF = True Or rsLoadNames.BOF = True Then
    
    Exit Sub
        Else
    Do While rsLoadNames.EOF = False
        cmbLoadNames.AddItem rsLoadNames("Username")
        rsLoadNames.MoveNext
    Loop

cmbLoadNames.Text = "Select a Username from the list"
End Sub

'Under your form load event call the load name sub. You will need to remove the code checking for a login status. That code will be used under your cmbLoadnames click event.

Call LoadNames 'Your combobox will now be filled with all the Usernames in the database.

'Under the combobox click event add the following -

If cmbLoadnames.Text = "" Or cmbLoadnames.Text = "Select a Username from the list" Then
   Msgbox "No Username selected." '......... etc
   Exit Sub
      Else
   Set rsLogin = New ADODB.Recordset
'This is where you will add your search clause of WHERE NAME = to something...
   rsLogin.Open "SELECT UserName, Password, RememberMeYesNo  FROM LoginData WHERE UserName = " & "'" & cmbLoadnames.text & "'", cnLogin, adOpenStatic, adLockOptimistic

txtUsername.Text = rsLogin!UserName
'Now use the part from your form load event to check if the user is to be remembered or not.

hello sir why is that there is no quote sir in posting or wrap in code for my code.when i am going to post my code why is that my code will not be highlight after posting...

0

Hi Jemz,

Starting at the bottom...

You probably did not wrap your code in the code tags. Previous Daniweb was named "code", where it is now still on your editor (advanced) marked as "#".
I suppose we all need to get used to the new Daniweb "look" and "feel". I personally find it ..... than before, but that is only my opinion - VERY PURPLISH":D

Back to your code, read the following on Events In VB6 -
http://www.developer.com/net/vb/article.php/1430631/Declaring-and-Raising-Events-in-Visual-Basic-6.htm

If your code works for you, fine. I just went through it quickly and all looks fine. The

If con.State = 1 Then 'Open
'Choose whether you want to close it or just leave it open. I personally like to close it and start afresh, depending on which form or events I am working on. You can leave it open if you like. The only thing for me is to trap errors BEFORE they occur, hence checking if it is open, if not then open it. Do not just hope it might be, and the user ends up with an application not responding or throwing errors...

I think this answered all of the above. If I might have missed something, just let me know.

0

Hi Jemz,

Starting at the bottom...

You probably did not wrap your code in the code tags. Previous Daniweb was named "code", where it is now still on your editor (advanced) marked as "#".
I suppose we all need to get used to the new Daniweb "look" and "feel". I personally find it ..... than before, but that is only my opinion - VERY PURPLISH":D

Back to your code, read the following on Events In VB6 -
http://www.developer.com/net/vb/article.php/1430631/Declaring-and-Raising-Events-in-Visual-Basic-6.htm

If your code works for you, fine. I just went through it quickly and all looks fine. The

If con.State = 1 Then 'Open
'Choose whether you want to close it or just leave it open. I personally like to close it and start afresh, depending on which form or events I am working on. You can leave it open if you like. The only thing for me is to trap errors BEFORE they occur, hence checking if it is open, if not then open it. Do not just hope it might be, and the user ends up with an application not responding or throwing errors...

I think this answered all of the above. If I might have missed something, just let me know.

hello sir thank you for the reply,sir so my code now is okey sir?thank you for checking my code...i also make another and modify it i remove the logIn table i will you show my other code as soon as possible..thank you again sir..for my question sir what is withevents in the declaration the one that you shown to me before...

0

Hi Jemz,

Starting at the bottom...

You probably did not wrap your code in the code tags. Previous Daniweb was named "code", where it is now still on your editor (advanced) marked as "#".
I suppose we all need to get used to the new Daniweb "look" and "feel". I personally find it ..... than before, but that is only my opinion - VERY PURPLISH":D

Back to your code, read the following on Events In VB6 -
http://www.developer.com/net/vb/article.php/1430631/Declaring-and-Raising-Events-in-Visual-Basic-6.htm

If your code works for you, fine. I just went through it quickly and all looks fine. The

If con.State = 1 Then 'Open
'Choose whether you want to close it or just leave it open. I personally like to close it and start afresh, depending on which form or events I am working on. You can leave it open if you like. The only thing for me is to trap errors BEFORE they occur, hence checking if it is open, if not then open it. Do not just hope it might be, and the user ends up with an application not responding or throwing errors...

I think this answered all of the above. If I might have missed something, just let me know.

hello sir here is the code that i modify sir...please correct me if i am wrong with my code...hoping for your positive responds...

Option Explicit

Public con As ADODB.Connection
Private WithEvents user_rs As ADODB.Recordset
Public cmd As ADODB.Command
Public m_user As String
Public m_pass As String
Public sql As String
Public attempts As Integer


Private Sub Form_Load()

Set con = New ADODB.Connection
Set user_rs = New ADODB.Recordset
Set cmd = New ADODB.Command


con.Open "provider = microsoft.jet.oledb.4.0; data source = " & App.Path & "\password.mdb;persist security info =false; jet oledb:database password=eldenz;"

  Set user_rs = New ADODB.Recordset
   
  user_rs.Open "select user_name,user_pass, rememberYesNo from security where rememberYesNo = 'Yes'", con, adOpenDynamic, adLockOptimistic

  If user_rs.BOF = True Or user_rs.EOF = True Then
   
    Else
    
       If Not user_rs!rememberYesNo = "No" Then
         txtuser.Text = user_rs!user_name
         txtpass.Text = user_rs!user_pass
         txtpass.PasswordChar = "*"
         chkbox.Value = 1
       End If
  End If
  
  
Me.Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
attempts = 0

End Sub

Private Sub cmdlog_Click()

 m_user = Trim(txtuser.Text)
 m_pass = Trim(txtpass.Text)

 Set user_rs = New ADODB.Recordset

  sql = "select COUNT (user_name) AS JEMEBE FROM SECURITY where user_name = '" & m_user & "' and user_pass ='" & m_pass & "'"
  user_rs.Open sql, con, adOpenDynamic, adLockOptimistic


  If user_rs.Fields("JEMEBE") = 0 Then
 
   attempts = attempts + 1
   MsgBox "Maybe You have Incorrect Username and Password", vbExclamation, "Please sign-up to register account"
   lblattempt.Caption = attempts
  
     If attempts = 1 Then
         MsgBox "you have 2 attempt left"
    
         ElseIf attempts = 2 Then
          MsgBox "You have 1 attempt remaining,this is your last chance."
       End If
  
       If attempts = 3 Then
         txtuser.Enabled = False
         txtpass.Enabled = False
         MsgBox "You have already consume your 3 attempts...try again tomorrow.!!"
        End If
        Exit Sub

    Else
      Unload Me
      Form6.Show
      user_rs.Close
  End If
   
   
End Sub
Private Sub cmdexit_Click()
Unload Me
End Sub

Private Sub lbllostpassword_Click()
  Dim ok As Integer
   ok = MsgBox("Sorry no internet connection... Do you want to continue?", vbYesNo + vbQuestion, "Please connect to the internet")
    
    If ok = vbYes Then
        Form15.Show
       Else
         End
      End If
    
End Sub

Private Sub lblremember_Click()
 
 If chkbox.Value = 0 Then
     chkbox.Value = 1
    Else
     chkbox.Value = 0
 End If
     
     
 If txtuser.Text = "Username" Or txtuser.Text = "'" Then
      chkbox.Value = 1
      txtuser.SetFocus
      Exit Sub
 End If
      
      
 m_user = Trim(txtuser.Text)

 Set user_rs = New ADODB.Recordset
 
  sql = "select user_name,user_pass,rememberYesNo from security where user_name = '" & m_user & "'"
  user_rs.Open sql, con, adOpenDynamic, adLockOptimistic

If user_rs.BOF = True And user_rs.EOF = True Then
 
       If chkbox.Value = 0 Then
             chkbox.Value = 1
            Else
             chkbox.Value = 0
       End If
       
        MsgBox "This Username is not yet registered", vbExclamation, "Register First"
     
          
    Else
           
          If user_rs!rememberYesNo = "No" Then
                user_rs!rememberYesNo = "Yes"
                 user_rs.Update
                Else
                    user_rs!rememberYesNo = "No"
                    user_rs.Update
           End If
           
 End If
  
End Sub

Private Sub lblsign_Click()
Form16.Show
Unload Me
End Sub


Private Sub txtpass_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
  cmdlog_Click
  Else
    If txtpass.Text = "Password" Then
       txtpass.Text = ""
       txtpass.PasswordChar = "*"
     End If
 End If
End Sub

Private Sub txtuser_KeyPress(KeyAscii As Integer)

 If txtuser.Text = "Username" Then
  txtuser.Text = ""
  End If
End Sub
0

Hi jemz,
If I am not wrong I think there is no code to check internet connection in your lbllostpassword_Click. What i think here is even if your computer is connected to or not connected to internet it will display the same message.

thankx

Edited by kinwang2009: n/a

0

Hi jemz,
If I am not wrong I think there is no code to check internet connection in your lbllostpassword_Click. What i think here is even if your computer is connected to or not connected to internet it will display the same message.

thankx

hello kinwang2009, thank you for the reply..i just put it there, i will just erase that...thank you...

Edited by jemz: n/a

0

i hope above are good and have not check on ide, you might be trying to get
sql = "select * from...............
user_rs.cursorlocation=aduseclient
user_rs.Open sql, con, adOpenDynamic, adLockPessimistic
Keep it up and try on ide

0

Hi jemz,
If I am not wrong I think there is no code to check internet connection in your lbllostpassword_Click. What i think here is even if your computer is connected to or not connected to internet it will display the same message.

thankx

thank you sir...

Edited by jemz: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.