ADO Fields collection

S

SimonW

Hi
I want to pass a number to a function that is used to refer to the field
collection of a recordset.

Function Next_Custom_Counter(n As Integer) 'number being passed is 0,
representing the 1st field in the recordset

Dim rs As ADODB.Recordset
Dim NextCounter As Long
Set rs = New ADODB.Recordset

'Open the ADO recordset.
rs.Open "custom", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic

'Get the next counter.
NextCounter = rs.Fields(n)

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Open table and get the current value of NextAvailableNumber,
'increment the value by 10, and save the value back into the table
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

rs.Fields(n) = NextCounter + 1
NextCounter = rs.Fields(n)
....
....

I have tried numerous ways to acheive this but keep getting errors messages.
"Error 3219: Operation is not allowed in this context"
My only documentation is DAO, and I want to avoid using that. Can anyone
tell me what I'm doing wrong TIA, Simon
 
S

SimonW

Hi folks, I've discovered what the problem is ! I can't close the object
becasue I have not used rs.Update in my code. Now fixed, thanks anyway ...

Simon
 

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