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

Problem moving to next or previous rec

Status
Not open for further replies.

livvie

Programmer
Apr 20, 2004
91
IE
--------------------------------------------------------------------------------

Hi
I have a form with 2 tabs in one tab there is a datasheet view of the table and the second tab has the details. The second tab displayes the details depending on which record you select in the first - this all works fine. My problem is that once I choose a record and look at it's details from there I want to move to the next record or previous record (numberically) without changing back to the first tab. Can this be done ir is it one funtionality or the other ?? Any help or ideas appreciated
 
Take a look at the Clone, MoveNext and MovePrevious methods of the Recordset object and at the Bookmark property of the Recordset and Form objects.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I have tried the Recordset Clone feature but I think my problem might be that I want to move thru all records in the table at this point so I mean the next id in the table. I have code in the ONCurrent event that enables me to display the correct record depending on the rec selected in the first form does this make the recordset just that rec ? Or maybe I just dont know how to do it.
 
In the detail forms use a RecordsetClone of the 1st form.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi

There is too much about how you are actually doing this which I do not know to give a definitive answer, but to move forwar a record in the list view tab, have a buttom with code like so in the onclick event

Me.MyListSubForm.FORM.RecordSetClone.MoveNext

then execute whatever code you use to synchronise the single view form (is that a subform too?) with the list form

You can then introduce additional buttons for previous, first, last using similar code but with the appropriate move command

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
I need to be able to move forward from the Details tab not the list tab. Moving from the list tab is OK but I am redoing a system for a co and they want the same functionality as the last one written in FoxPro. They don't want to have to switch back to the list tab to move on or back on record.
OK when I debug I am being moved to the correct record but I am not actually moving in the datasheet which is where I am getting the Current Rec details from so when I press the button the recordset moves to the next rec but the display doesn't. I have tried running the code from OnCurrent at this point.
This is the ONCurrent Code
Private Sub Form_Current()
'Populate the Estimates tab with the details of the record selected here


Dim strParentDocName As String

On Error Resume Next
strParentDocName = Me.Parent.name

If Err <> 0 Then
GoTo Form_Current_Exit
Else
On Error GoTo Form_Current_Err
Me.Parent![fsubEstDets].Requery
End If

Form_Current_Exit:
Exit Sub

Form_Current_Err:
MsgBox Err.Description
Resume Form_Current_Exit
 
Hi

I am not talking about move forward from the list tab. In you explanation you say the row displayed in the detail tab is the current row of the list tab, so by having a button which moves (ie changes) the current record on the list tab, you will move the detail record too. The user does not haev to delect the tab with the list view on it in order to manipulate the recordsetclone property

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Sorry Ken I misunderstood you. That is exactly what I want to do.
When I try using the clone code the current record in the recordset seems to be the first record not the one selected by the user.
Sorry for going around in circles here but this is driving me mad.
 
Take a look at the FindFirst method and NoMatch property.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi

Have knocked up a quick example

it has a form, on form is a tab control, on first tab is a (sub) form in datasheet view, on second tab is a (sub) form in form view

on "Main" form is a command button with code like so:

Option Compare Database
Option Explicit

Private Sub cmdNext_Click()
Dim Rs As DAO.Recordset
'
On Error GoTo Error_cmdNext
With Me.frmList.Form
.RecordsetClone.MoveNext
.Bookmark = .RecordsetClone.Bookmark
Set Rs = Me.frmSingle.Form.RecordsetClone
Rs.FindFirst "lngId = " & !lngId
If Rs.NoMatch Then
Else
Me.frmSingle.Form.Bookmark = Rs.Bookmark
End If
End With
Exit_cmdNext:
Exit Sub
Error_cmdNext:
If Err.Number = 3021 Then
With Me.frmList.Form
.RecordsetClone.MoveLast
.Bookmark = .RecordsetClone.Bookmark
End With
Resume Exit_cmdNext
Else
MsgBox "Error " & Err.Number & " " & Err.Description
End If
End Sub

it gives desired result, needs proper error trapping

A reference to DAO library is required

good luck

if you want I can send you the mdb file, if you want this post your EMail address

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Thats great Ken
Can you mail it to me gaillimh96@hotmail.com.
I am using Access adp and ADO does that make any difference. Also this might be a clue to why I cannot get it to work. When I add a new rec the rec is visible immediately in the list but I have to close the app and open again to see it inthe details eventhough I have a requery in.
 
Ken
FYI
I have copied my forms and code into mdb and it is fine but it won't work with adp. I'll keep fiddling with it and I might get it. Thanks for all your time and effort.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top