Note that there are some explanatory texts on larger screens.

plurals
  1. POOperation is not allowed when the object is open
    primarykey
    data
    text
    <p>Im getting that error when I try to code my vb6 Log in method. I check all the recordset and I cant see any open recordset. Why am I getting this error? The logic of this Log in program is that as the user enters a username and password in the textfield, I check if it is correct based on the database(ms access) value, and terminate the program if he entered invalid username and password 3x. When I tried my program it's working on correct username and password but if I try to make 3x error input it gives me that error just in 2nd try of invalid input.</p> <p>Can someone help me?</p> <p>Here's my code:</p> <pre><code>Dim Con As New ADODB.Connection Dim Rs As New ADODB.Recordset Dim Rs2 As New ADODB.Recordset Dim ctr As Integer Dim cmdCommand As New ADODB.Command Dim have As Integer Dim Username As String Dim Password As String Private Sub cmdLogin_Click() If ctr &lt;&gt; 3 Then If txtUsername.Text = Username And txtPassword.Text = Password Then MsgBox "Login Successful!!" MDIForm1.Show Unload Me ElseIf txtUsername.Text &lt;&gt; Username And txtPassword.Text &lt;&gt; Password Then MsgBox "Invalid Log in!" txtUsername.Text = "" txtPassword.Text = "" txtUsername.SetFocus ElseIf txtUsername.Text &lt;&gt; Username And txtPassword.Text = Password Then MsgBox "Invalid Log in!" txtUsername.Text = "" txtPassword.Text = "" txtUsername.SetFocus ElseIf txtUsername.Text = Username And txtPassword.Text &lt;&gt; Password Then MsgBox "Invalid Log in!" txtUsername.Text = "" txtPassword.Text = "" txtUsername.SetFocus ElseIf txtUsername.Text = "" And txtPassword.Text = "" Then MsgBox "Invalid Log in!" txtUsername.Text = "" txtPassword.Text = "" txtUsername.SetFocus Else txtUsername.Text = "" txtPassword.Text = "" txtUsername.SetFocus End If ctr = ctr + 1 Else MsgBox "You are not a valid user! The Program will be terminated" End End If End Sub Private Sub Form_Load() Call OpenConnection With Rs .ActiveConnection = Con .CursorType = adOpenDynamic .CursorLocation = adUseClient .LockType = adLockOptimistic End With End Sub Private Sub OpenConnection() If Con.State = 1 Then Con.Close End If Set Con = New ADODB.Connection Con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;DataSource=C:\Users\User\Documents\dbMMM.accdb;Persist Security Info=False;" Con.Open End Sub Private Sub txtUsername_LostFocus() With Rs2 .ActiveConnection = Con .Source = "Select * From tblUser where UserName = '" &amp; txtUsername.Text &amp; "' " 'The highlight of my error is in this line .CursorType = adOpenDynamic .CursorLocation = adUseClient .LockType = adLockOptimistic .Open have = 0 If Rs2.EOF = False Then Rs2.MoveFirst Do Username = Rs2.Fields(0) Password = Rs2.Fields(1) Rs2.MoveNext Loop Until Rs2.EOF = True Rs2.Close End If End With End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload