Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime error "3704"

Status
Not open for further replies.

Collin79

Programmer
Dec 31, 2000
31
MX
Hi:

I'm designing a form, in it I've done a command Buttom that it should save the captured data to an Access Database and I've wrote this code:

Private Sub Command1_Click()
If DataCombo1.BoundText = "GNP" Then
Dataenvironment1.rsGNP.AddNew
Dataenvironment1.rsGNP.Update

ElseIf DataCombo1.BoundText = "SCA" Then
Dataenvironment1.rsSCA.AddNew
Dataenvironment1.rsSCA.Update

ElseIf DataCombo1.BoundText <> &quot;GNP&quot; And DataCombo1.BoundText <> &quot;SCA&quot; Then
Dataenvironment1.rsSCA.AddNew
Dataenvironment1.rsSCA.Update

Endif

An error occurs when I try to save the data captured:

Runtime Error &quot;3704&quot;

Operation is not allowed when object is closed


Any tip?

Thanks

Collin79
 
Now in this code, you are using two objects :
DataCombo1 and
Dataenvironment1.

One of these objects haven't been opened before you are trying to conduct the operation. Either this, or the object has been closed some how before you could complete the operation.

It should show you the line where you are facing the error. That way, you will know which object you are facing error in.
 
The error goes to this line:

Dataenvironment1.recordsource.AddNew
 
In the code that you mentioned above, I do not see a &quot;Dataenvironment1.recordsource.AddNew&quot; but only &quot;Dataenvironment1.rsGNP.AddNew&quot;. If they are both the same, then please check if you created the recordsource object before you tried to add new records to it.
 
Hey Antzz

Thanks for your info, but I'm new on Visual Basic, so How I can set the recordsource object? I need to do it with code or Do I need to build an object on my form?

Collin79
 
I will need more details from you. From your code it seems like you are trying to use a bounded grid. Is that true?

 
No, I'm not using a Grid, I have done a form, in it I'm using a Data Combo, which shows companies name, depending of its Bound Text I need to change the Datafield and DataMember. DataSource is the same for all objects (Dataenvironment1)


If DataCombo1.BoundText = &quot;GNP&quot; Then
sol.DataMember = tblGNP
sol.DataField = sol
Assurre.DataMember = tblGNP
Assurre.DataField = Assured
.
.
etc.
Elseif Datacombo1.boundtext= &quot;SCA&quot; then
.
.
etc.
Endif

This code works ok, my problem is when I want to save the captured data with the command buttom on click event as above mentioned (1st Post)

If you can give me a hint I really appreciate.

Thanks

Collin79

P.S. I'm desperated!!!!



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top