By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,985 Members | 1,777 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,985 IT Pros & Developers. It's quick & easy.

log out problem. help !

P: 16
this is my login form.
i got other form log out button that go to this log in form to login again
when i login again it will pop up this error:
operation is not allowed when the object is open
Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim intFounds As String
  3. strCNString = "Data Source=" & App.Path & "\PayrollBakeryDB.mdb"
  4. cn.Provider = "Microsoft Jet 4.0 OLE DB Provider"
  5. cn.ConnectionString = strCNString
  6. cn.Open
  7. intFounds = 2
  8.     With rs
  9.         .Open "SELECT s_username,s_password,m_username,m_password,b_username,b_password FROM Employees", cn, adOpenDynamic, adLockOptimistic
  10.          Do Until .EOF
  11.             If txtname.Text = !b_username And txtpass.Text = !b_password Then
  12.                 intFounds = 1
  13.                 P_BossMenu.Show
  14.                 Exit Sub
  15.             ElseIf txtname.Text = !m_username And txtpass.Text = !m_password Then
  16.                 intFounds = 1
  17.                 P_ManagerMenu.Show
  18.                 Exit Sub
  19.             ElseIf txtname.Text = !s_username And txtpass.Text = !s_password Then
  20.                 intFounds = 1
  21.                 P_StaffMenu.Show
  22.                 Exit Sub
  23.  
  24.             End If
  25.             .MoveNext
  26.           Loop
  27.           .MoveFirst
  28.           If intFounds = 2 Then
  29.                    MsgBox "Wrong username or password", vbExclamation, "Search"
  30.           End If
  31.  
  32.      End With
  33.  
  34. cn.Close
  35.  
  36.  
Apr 10 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 5K+
P: 8,434
At what line of code does the error occur? And what version of VB is this?

Hm... on further consideration, I'd hazard a guess that you haven't closed the recordset (or connection, or something), so VB isn't happy about you trying to open it again.

Note that if this pasted code is accurate, executing one of the Exit Sub statements will bypass the Close down the bottom, and leave things open. (This may or may not be what you intended.)
Apr 10 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.