Record Set

shamas21

Registered User.
Local time
Today, 22:54
Joined
May 27, 2008
Messages
162
Hi All

Can someone tell me how i can determine the row which my table is current on.

i.e.

Code:
Sub Updatefields()
Set cn = CurrentProject.Connection
Set rs = New ADODB.Recordset
rs.Open "Table1", cn
 
End Sub
 
from help (Recordset Object)
"When you open a Recordset, the current record is positioned to the first record (if any) and the BOF and EOF properties are set to False. If there are no records, the BOF and EOF property settings are True."
 
from help (Recordset Object)
"When you open a Recordset, the current record is positioned to the first record (if any) and the BOF and EOF properties are set to False. If there are no records, the BOF and EOF property settings are True."

Thanks, but lets say I open the table manually and highlight row 3 for example. Is there a way of VBA telling me that i have row 3 highlighted?
 
i think the only way is with a recordset - rs, form (form view or datasheet view) or report.
 
if you open a table and click on row4, the recordset cursor at the bottom will show 4.

what exactly are you trying to do with this information
 
Thanks, but lets say I open the table manually and highlight row 3 for example. Is there a way of VBA telling me that i have row 3 highlighted?
If you open a table manually then as Gemma says you can see which record you are at. This will not affect any VBA code that opens the recordset.
 
If you use an autonumbering field and it is in the first column of the table, you could do something like ...

MsgBox rs.Fields(0)

It will give you the value of the first field of the first column (Fields(1) the second, Fields(2) the third, etc.) You would need to increment or decrement to get to wherever if you know where it is you are going.

Look up "Move" in Access Help (Recordset.Move method). It might be able to provide more information in that area.

-dK
 
If you use an autonumbering field and it is in the first column of the table, you could do something like ...

MsgBox rs.Fields(0)

It will give you the value of the first field of the first column (Fields(1) the second, Fields(2) the third, etc.) You would need to increment or decrement to get to wherever if you know where it is you are going.

Look up "Move" in Access Help (Recordset.Move method). It might be able to provide more information in that area.

-dK
But remember that Autonumber does not guarantee there won't be gaps in the sequence - the only guarantee is that they are unique
 

Users who are viewing this thread

Back
Top Bottom