Error when running this code

A

Andy Levy

Im getting "Error 3219: Operation Not Allowed In This Context" when
running the following code which feeds particular values from one table into
another. Does anyone know how i can resolve it. Thanks




Dim pst As ADODB.Recordset
Set pst = New ADODB.Recordset
pst.Open "SELECT * FROM tblLog", CurrentProject.Connection, adOpenDynamic,
adLockOptimistic

Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.Open "SELECT URID,* FROM items WHERE URID =" & varPK,
CurrentProject.Connection

pst.MoveLast

Dim flda As Field
Dim fldb As Field

For Each flda In rst.Fields 'items

For Each fldb In pst.Fields 'log

If flda.name = fldb.name Then
If Not IsNull(flda.Value) Then
fldb.Value = flda.Value
End If
End If
Next fldb
Next flda
 
A

Andy Levy

Hi

The error is occuring at the following line

fldb.Value = flda.Value

I have tried replacing it with

debug.print flda.value

and it lists the values without problem. I have also checked the field Type
in both tables to make sure they match.

I cant see why it wont copy the values over.

thanks

AL



----- Original Message -----
From: "Ken Snell" <[email protected]>
Newsgroups: microsoft.public.access.formscoding
Sent: Sunday, October 26, 2003 3:54 AM
Subject: Re: Error when running this code
 
A

Andy Levy

what i think i need to change that line to is something that evaluates to

pst!fldb.name = rst!flda.name

do you know the best way of writing an eval that will do that?

Thanks

AL
 
A

Andy Levy

Ive done it

The problem seems to be it didnt like the rst.close and pst.close commands i
put at the end.
 

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

Similar Threads


Top