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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find the next record without queries

Status
Not open for further replies.

waldemar

Programmer
Nov 15, 2001
245
DE
I want to program two buttons that switch entries in a table-like form. The buttons (up and down) need to look one entry ABOVE and one entry UNDER the current record to get that id (and later call a simple function switchentries(entryid0, entryid1)).

I COULD open a copy of the displayed recordset, move to the current record and then movePrevious or moveNext, BUT is there a more elegant way to find out these ids? Is it possible to this with "bookmarks" or some tricky form-function?

Thanks in advance
waldemar
 
As presented, I simply do not understand.

You cannot "MOVE" entries in a recordset (Table). They are not "Ordered" in the recordset (Table or Query), except via the criteria used to retrieve them (evem when that criteria is implicit or default).



MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Thanks. Alright, I found what I was looking for. For people interested: These are the subs for the two buttons (up/down) - this is similar to ordered lists one sees in many applications...

Private Sub buttonup_Click()
Dim rs As Recordset, order0 As Long, order1 As Long
order0 = Me.subform.Form.order
Set rs = Me.subform.Form.RecordsetClone
rs.FindFirst "order=" & order0
If Not rs.NoMatch Then
rs.MovePrevious
order1 = rs![order]
'MsgBox Str(order0) & " - " & Str(order1)
Call switchentries(order0, order1)
End If
rs.Close: Set rs = Nothing
End Sub

Private Sub buttondown_Click()
Dim rs As Recordset, order0 As Long, order1 As Long
order0 = Me.subform.Form.order
Set rs = Me.subform.Form.RecordsetClone
rs.FindFirst "order=" & order0
If Not rs.NoMatch Then
rs.MoveNext
order1 = rs![order]
'MsgBox Str(order0) & " - " & Str(order1)
Call switchentries(order0, order1)
End If
rs.Close: Set rs = Nothing
End Sub


Regards
waldemar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top