Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOW TO retrieve the CurrentRecordPosition ???

Status
Not open for further replies.

marco02

Programmer
Feb 19, 2002
35
0
0
US
Hi guys,

For my application I need to retrieve the record/row the user has selected. How do I do that ?

Let's say the user chooses to launch the code on record 49:
1) he opens the table
2) he clicks in record/row number 49
3) and clicks command button "Launch" of my form or CommandBar.

----> How do I retrieve the record/row the user's has
selected though ??

Thank you so much for your help!

Marco.

[flush2]
 
I am not sure if you are using ADO or not but if you are you can use this

rs.open
rs.move iRecordNumber
sDats = rs("fieldData")
rs.close

Hope this helps. If you choose to battle wits with the witless be prepared to lose.
[machinegun][hammer]
 
Where is your data displayed?? In case of a DataGrid Control :

Private Sub Form_Load()
Dim conn As New ADODB.Connection
Dim rst As New ADODB.Recordset

'Get connected to DB
conn.ConnectionString = "..."
conn.CursorLocation = adUseClient
conn.Open

rst.Open "SELECT * customers", conn

Set DataGrid1.DataSource = rst
End Sub

Private Sub Command1_Click()
Dim rst As ADODB.Recordset
Dim CustomerID as Long
Set rst = DataGrid1.DataSource
CustomerID = rst.Fields("CustomerID")

frmCustomerDetail.Show
frmCustomerDetail.ShowCustomer(CustomerID)
End Sub

Showcustomer is a public Sub on the frmCustomerDetail form that shows details for Customer with the given ID.

Let me know if you need to know more,

Jan If this response was usefull to you, please mark it with a Star!
 
I am using dbgrid with dao, so is there any way to set focus on a particular cell in the dbgrid..?? Its nice to be important, but it's more important to be nice.
 
I think DAO works the same way as ADO, in this case (recordset).

Focusing one specific cell can be done like this :
DataGrid1.Row = 5
Datagrid1.Col = 3

Greetz,
Jan If this response was usefull to you, please mark it with a Star!
 
Thank you Jantie and Foada BUT,

-> Jantie, your code looks like what I want to do but I'm using a Table. My user visually scans a table and selects the row he is interested in in the table directly. Then launches the code. That's when I want to retrieve the RowNumber he selected in the TABLE.

So, is there a way to do the same with a TABLE in DAO ?
[sorry I use DAO and i don't unserstand the DataGrid thing]

-> Foada, I don't know the iRecordNumber yet because the user launches the code after having selected his row. And when I open the recordset(TABLE), the RecordCursor is set at the beginning of the recordset of course :-(

-> any idea how to do that with DAO guys ?

Thanks so much for your help, [thumbsup2]

marco
 
When you say you're using a Table, is this an Access application running in Access? Do you have an Access table open alongside your form? Is that what you mean by Table?
If that's the case... I can't help you.
How 'bout displaying the data in a DataGrid or something else on the form itself.
 
Yeah Schroeder, actually that's what I'm gonna do: dump the table's data into a Form and work from there.
The user will just have to change his habits and do what I tell him !! [hammer]
Now, who's the master he ?
[pc2]

... but if somebody knows how to "retrieve directly the CurrentRecord of an opened access Table", well, I'm still interested. Thanks.

Marco
 
If you recordset is attached to the table, and your provider supports it - you may be able to use the .AbsolutePosition property of the recordset. Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top