3 Replies - 1398 Views - Last Post: 17 October 2012 - 02:07 PM Rate Topic: -----

#1 LogicTricks  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 08-October 11

Operation is not allowed when the object is open.

Posted 12 October 2012 - 07:27 PM

hello guys , im trying to open multiple recordset but how can i close the other one ?
When i try to debug the error pointing at rs3.Open query, cn, adOpenDynamic, adLockPessimistic(BOLD)

ElseIf Index = 2 Then
If MsgBox("Save The Product?", vbQuestion + vbYesNo, "Message") = vbNo Then: Exit Sub
query = "Insert into ProductLabel(ProductId,ProductName,Category,SubCategory,Supplier,Ceiling,Flooring,Reorder,Critical,Markup,Price)Values('" & Text1(0).Text & "','" & Text1(1).Text & "','" & Combo1(0).Text & "','" & Combo1(1).Text & "','" & Combo1(2).Text & "','" & Text1(5).Text & "','" & Text1(6).Text & "','" & Text1(7).Text & "','" & Text1(8).Text & "','" & Text1(9).Text & "','" & Text1(10).Text & "');"
'
'" & Combo3.Text & "','" & Text3.Text & "','" & Text4.Text & "','" & Text5.Text & "','" & Text6.Text & "','" & Text7.Text & "','" & Text8.Text & "');"
[b]rs3.Open query, cn, adOpenDynamic, adLockPessimistic[/b]
Textclear
Frame15.Visible = True
Timer1.Enabled = True




Is This A Good Question/Topic? 0
  • +

Replies To: Operation is not allowed when the object is open.

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4337
  • View blog
  • Posts: 12,137
  • Joined: 18-April 07

Re: Operation is not allowed when the object is open.

Posted 13 October 2012 - 03:54 PM

I can only assume from your error that you used rs3 before and you are trying to open a new query with it. Remember, after opening it and running your query, you close it using close() before you can reopen it with a new query.

rs.Open ...
rs.Close()

' Now reopen with another query
rs.Open ...



Hope this helps. :)
Was This Post Helpful? 0
  • +
  • -

#3 LogicTricks  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 08-October 11

Re: Operation is not allowed when the object is open.

Posted 13 October 2012 - 03:57 PM

its ok now , thank you ...
Was This Post Helpful? 0
  • +
  • -

#4 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Operation is not allowed when the object is open.

Posted 17 October 2012 - 02:07 PM

Also, don't use a recordset when you're doing an insert. Recordsets are the result of select queries. You're not trying to retrieve any data, you're trying to insert data. Use a command object.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1