trouble with this code...

R

rocco

Hello,
I have a procedure which will iterate on any controls of an unbound form and
use their values to populate few tables.
I’ll post some code here:

(…)
RST.Open "tblMINIPLUS_A", CurrentProject.Connection, adOpenDynamic,
adLockOptimistic
RST.AddNew
For i = 0 To RST.Fields.Count - 4
-code to fill table’s fields with values-
Next i
RST.Update
RST.Close

RST.Open "tblMINIPLUS_B", CurrentProject.Connection, adOpenDynamic,
adLockOptimistic
RST.AddNew
-code to fill table’s fields with values-
RST.Update
RST.Close

RST.Open "tblMINIPLUS_C", CurrentProject.Connection, adOpenDynamic,
adLockOptimistic
RST.AddNew
For i = 0 To RST.Fields.Count - 4
-code to fill table’s fields with values-
Next i
RST.Update
RST.Close

Set RST=nothing

The -code to fill table’s fields with values- works fine: I have tested in
many situation.
But I receive an error message saying: “The expression you entered refers to
an object that is closed or doesn’t existâ€.
Why is it happening?

I have found that adding
set RST=nothing
set RST= new ADODB.recordset
betweene the RST.close and the next RST.Opne seems to solve the issue but I
cannot understand why and if this is the right solution.

Rocco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top