CurrentRecord equivalent in ADO

M

mistux

What is the syntax for telling me what current record I am on in
record set using ADO? In DAO it is rst.CurrentRecord, but I can't see
to find the equivalent in ADO!!

Old DAO code:

'If Me.RecordsetClone.BOF = False Then
' Me.RecordsetClone.MoveFirst
'
' For i = 1 To Me.CurrentRecord
' If strItem = Me.RecordsetClone.Fields("ComboCustPartNum"
Then
' lngRunningTot = lngRunningTot
Me.RecordsetClone.Fields("QtyGood")
' End If
' Me.RecordsetClone.MoveNext
' Next i
' Me.TotalQtyToRecord = lngRunningTot
'End If

Basically I am trying to find the sum of the QtyGood up to (an
including) the current record that I am looking at when on a form.
even tried to change from a recorset clone of the current form to jus
making a seperate recordset, but nothing seem to work, the code abov
just keeps adding the first QtyGood to itself. It is like it neve
sees the next records value
 
D

David Lloyd

The AbsolutePosition property indicates the position within a recordset for
an ADO recordset.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.



What is the syntax for telling me what current record I am on in a
record set using ADO? In DAO it is rst.CurrentRecord, but I can't seem
to find the equivalent in ADO!!

Old DAO code:

'If Me.RecordsetClone.BOF = False Then
' Me.RecordsetClone.MoveFirst
'
' For i = 1 To Me.CurrentRecord
' If strItem = Me.RecordsetClone.Fields("ComboCustPartNum")
Then
' lngRunningTot = lngRunningTot +
Me.RecordsetClone.Fields("QtyGood")
' End If
' Me.RecordsetClone.MoveNext
' Next i
' Me.TotalQtyToRecord = lngRunningTot
'End If

Basically I am trying to find the sum of the QtyGood up to (and
including) the current record that I am looking at when on a form. I
even tried to change from a recorset clone of the current form to just
making a seperate recordset, but nothing seem to work, the code above
just keeps adding the first QtyGood to itself. It is like it never
sees the next records value.


--
mistux
------------------------------------------------------------------------
mistux's Profile: http://www.officehelp.in/member.php?userid=107
View this thread: http://www.officehelp.in/showthread.php?t=752516
Visit - http://www.officehelp.in |
http://www.officehelp.in/archive/index.php |
http://www.officehelp.in/index/index.php
 
D

Dirk Goldgar

mistux said:
What is the syntax for telling me what current record I am on in a
record set using ADO? In DAO it is rst.CurrentRecord, but I can't
seem to find the equivalent in ADO!!

Old DAO code:

'If Me.RecordsetClone.BOF = False Then
' Me.RecordsetClone.MoveFirst
'
' For i = 1 To Me.CurrentRecord
' If strItem = Me.RecordsetClone.Fields("ComboCustPartNum")
Then
' lngRunningTot = lngRunningTot +
Me.RecordsetClone.Fields("QtyGood")
' End If
' Me.RecordsetClone.MoveNext
' Next i
' Me.TotalQtyToRecord = lngRunningTot
'End If

Basically I am trying to find the sum of the QtyGood up to (and
including) the current record that I am looking at when on a form. I
even tried to change from a recorset clone of the current form to just
making a seperate recordset, but nothing seem to work, the code above
just keeps adding the first QtyGood to itself. It is like it never
sees the next records value.

Um, CurrentRecord is not a DAO property; it's a property of the form,
as you'll see if you look closer at the "old" code you posted. Why are
you trying to replace the DAO code with ADO code? If your form is in an
..mdb file, the form's recordset is a DAO recordset (unless you
explicitly bound it to an ADO recordset using code).
 
M

mistux

Dirk Goldgar
Um, CurrentRecord is not a DAO property; it's a property of the form,
as you'll see if you look closer at the "old" code you posted. Why are
you trying to replace the DAO code with ADO code? If your form is in an
..mdb file, the form's recordset is a DAO recordset (unless you
explicitly bound it to an ADO recordset using code).

--
Dirk Goldgar, MS Access MVP

[/QUOTE said:
Ooo, now there is a train of thought that I did not get on. The for
that is is on is now in an ADP (not MDB) and DAO is not being used.
thought that was the issue, but it looks as if it is not. Now I a
even more confused as to why it is not working. What I get is the ver
first qty being "found" or at least "used" every time
 
D

Dirk Goldgar

mistux said:
Dirk Goldgar
Um, CurrentRecord is not a DAO property; it's a property of the form,
as you'll see if you look closer at the "old" code you posted. Why
are you trying to replace the DAO code with ADO code? If your form
is in an .mdb file, the form's recordset is a DAO recordset (unless
you explicitly bound it to an ADO recordset using code).

--
Dirk Goldgar, MS Access MVP

[/QUOTE said:
Ooo, now there is a train of thought that I did not get on. The form
that is is on is now in an ADP (not MDB) and DAO is not being used.
I thought that was the issue, but it looks as if it is not. Now I am
even more confused as to why it is not working. What I get is the
very first qty being "found" or at least "used" every time.

I believe I see what the problem is, and it doesn't have anything to do
with differences between DAO and ADO. It may or may not have anything
to do with the differences between MDBs and ADPs; I don't know offhand.

In your code, you refer to the RecordsetClone over and over again. In
some versions of Access, each reference to the form's RecordsetClone
property creates a new clone of the recordset, while in other versions,
a single clone recordset is created the first time the property is
referred to, and that same recordset is returned each subsequent time
you refer the the RecordsetClone property. Obviously, if a *new*
recordset is created to be passed back to the RecordsetClone property,
that recordset doesn't inherit the state of any previous recordset that
was passed back.

I don't know whether this is a change with Access 2003, or whether it
has to do with the fact that this is an ADP -- more likely the former,
I'd guess -- but I'd suggest you revise your code like this:

'----- start of revised code -----
With Me.RecordsetClone

If .RecordCount <> 0 Then

.MoveFirst

For i = 1 To Me.CurrentRecord
If strItem = .Fields("ComboCustPartNum") Then
lngRunningTot = lngRunningTot + .Fields("QtyGood")
End If
.MoveNext
Next i

Me.TotalQtyToRecord = lngRunningTot

End If

End With
'----- end of revised code -----

That should ensure that only one RecordsetClone is used for the whole
process.
 

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