9 Replies - 1500 Views - Last Post: 27 September 2016 - 12:07 AM Rate Topic: -----

#1 dongodu   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 64
  • Joined: 30-March 09

run-time error '3704' operation is not allowed when the object

Posted 24 September 2016 - 01:49 AM

Private Sub bal1()
Dim cnupdate As New ADODB.connection
Dim rsupdate As New ADODB.Recordset
Dim reply As String


Call connection(cnupdate, App.Path & "\Seeyou.mdb", "endromida")
'Call connection(cnupdate, "\\SEEYOU-PC\shared\Seeyou.mdb", "endromida")
Call Recordset(rsupdate, cnupdate, "SELECT * FROM fabric_shirt WHERE fbcode='" & txtFbcode.Text & "'")

If rs.BOF And rs.EOF Then -----> Error
    MsgBox "recordset is empty"
Else
reply = rsupdate.Fields!fbcode

With rsupdate
.Fields!iss = txtFbIss.Text
Call bal1
.Fields!bal = Text1.Text
.Update
End With

End If

Set cnuser = Nothing
Set rsuser = Nothing


End Sub


Is This A Good Question/Topic? 0
  • +

Replies To: run-time error '3704' operation is not allowed when the object

#2 andrewsw   User is offline

  • Bouncy!
  • member icon

Reputation: 6563
  • View blog
  • Posts: 26,615
  • Joined: 12-December 12

Re: run-time error '3704' operation is not allowed when the object

Posted 24 September 2016 - 02:05 AM

When the object is what? (Is clos..?)

You need to provide a clear question. Post the full error message, describe what's going on and what happens. Ask a question. You've made enough posts to know these requirements by now.
Was This Post Helpful? 0
  • +
  • -

#3 dongodu   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 64
  • Joined: 30-March 09

Re: run-time error '3704' operation is not allowed when the object

Posted 24 September 2016 - 02:07 AM

run-time error '3704' operation is not allowed when the object is closed
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw   User is offline

  • Bouncy!
  • member icon

Reputation: 6563
  • View blog
  • Posts: 26,615
  • Joined: 12-December 12

Re: run-time error '3704' operation is not allowed when the object

Posted 24 September 2016 - 02:14 AM

And..? Your question remains in danger of being closed because you are not making the effort to provide a clear question.

The error message seems clear, though. It looks like your recordset isn't open. What do your two methods do?

Note that it is a bad idea to name your methods 'connection' and 'Recordset'. Show some imagination, these names are obviously already in use.
Was This Post Helpful? 0
  • +
  • -

#5 dongodu   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 64
  • Joined: 30-March 09

Re: run-time error '3704' operation is not allowed when the object

Posted 24 September 2016 - 02:19 AM

i am trying to update a record, which is already saved.
Rather than methods 'connection' and 'Recordset' which method can i use
From very long time i am using the same method in VB6
Was This Post Helpful? 0
  • +
  • -

#6 maj3091   User is offline

  • D.I.C Lover
  • member icon

Reputation: 331
  • View blog
  • Posts: 1,998
  • Joined: 26-March 09

Re: run-time error '3704' operation is not allowed when the object

Posted 24 September 2016 - 03:04 PM

Should this line below not refer to the recordset in use (ie: rsUpdate), and not rs?

If rs.BOF And rs.EOF Then

Was This Post Helpful? 0
  • +
  • -

#7 dongodu   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 64
  • Joined: 30-March 09

Re: run-time error '3704' operation is not allowed when the object

Posted 25 September 2016 - 06:07 AM

Private Sub bal1()
Dim cnupdate As New ADODB.connection
Dim rsupdate As New ADODB.Recordset
Dim reply As String


Call connection(cnupdate, App.Path & "\Seeyou.mdb", "endromida")
'Call connection(cnupdate, "\\SEEYOU-PC\shared\Seeyou.mdb", "endromida")
Call Recordset(rsupdate, cnupdate, "SELECT * FROM fabric_shirt WHERE fbcode='" & txtFbcode.Text & "'")

If rsupdate.BOF And rsupdate.EOF Then
reply = rsupdate.Fields!fbcode
Else
 MsgBox "recordset is empty"
 
With rsupdate
.Fields!iss = txtFbIss.Text
Call bal1
.Fields!bal = Text1.Text
.Update
End With

End If

Set cnuser = Nothing
Set rsuser = Nothing


End Sub

Same Error again, after i correct the code
Was This Post Helpful? 0
  • +
  • -

#8 maj3091   User is offline

  • D.I.C Lover
  • member icon

Reputation: 331
  • View blog
  • Posts: 1,998
  • Joined: 26-March 09

Re: run-time error '3704' operation is not allowed when the object

Posted 25 September 2016 - 10:10 AM

And the error is where?

Did you check that the connection is actually open?

Did you try to debug your code (andrewsw has a link in his signature if you don't know how)
Was This Post Helpful? 0
  • +
  • -

#9 dongodu   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 64
  • Joined: 30-March 09

Re: run-time error '3704' operation is not allowed when the object

Posted 26 September 2016 - 11:02 AM

If rsupdate.BOF And rsupdate.EOF Then


Error in this line
i think connection is open still
Was This Post Helpful? 0
  • +
  • -

#10 maj3091   User is offline

  • D.I.C Lover
  • member icon

Reputation: 331
  • View blog
  • Posts: 1,998
  • Joined: 26-March 09

Re: run-time error '3704' operation is not allowed when the object

Posted 27 September 2016 - 12:07 AM

View Postdongodu, on 26 September 2016 - 07:02 PM, said:

If rsupdate.BOF And rsupdate.EOF Then


Error in this line
i think connection is open still


You think it's open??? It's either open or it isn't.

Only you can test if it's open, so you need to do something to help yourself here.

As mentioned previously, if you don't know how to debug your code, Andrewsw has a link in his signature with details on how to do it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1