S
Stephen
I have been reading all sorts of forum on this topic and still cannot get
this thing to work:
I have a continuous subform that display 10 records in teh viewable area. I
am trying to create a command button ("Next Page") on the main form that
will advance the records on the subform so that it displays teh next set of
10 records (mimics a page-down effect).
I have the following code (not there is a field on the main form called
"lastrecord" which keeps track of which record position has teh curent
focus.
Option Compare Database
Option Explicit
Dim ORDERRECORDS As Integer ' number of records in the recordset
Dim RecordsToMove As Integer ' number of records to advance
Const FORMRECORDS = 10 ' ' the number of viewable records
Private Sub NextPage_Click()
Dim targetForm As Form
Set targetForm =
Forms!sfrmOrder!sfrmOrderSubformTicket!sfrmOrderSubformTicketDetail.Form
ORDERRECORDS = targetForm.Recordset.RecordCount
If ORDERRECORDS > FORMRECORDS Then
If ORDERRECORDS - Me.LastRecord > FORMRECORDS Then
RecordsToMove = Me.LastRecord + FORMRECORDS - 1
Me.LastRecord = Me.LastRecord + FORMRECORDS - 1
else
RecordsToMove = Me.LastRecord + FORMRECORDS
Me.LastRecord = Me.LastRecord + FORMRECORDS
End If
Me.sfrmOrderSubformTicketDetail.SetFocus
DoCmd.GoToRecord , , acNext, RecordsToMove
End If
When I run this code, I get the following error:
Runtime 2105: You can't go to the specified record.
Any help?
this thing to work:
I have a continuous subform that display 10 records in teh viewable area. I
am trying to create a command button ("Next Page") on the main form that
will advance the records on the subform so that it displays teh next set of
10 records (mimics a page-down effect).
I have the following code (not there is a field on the main form called
"lastrecord" which keeps track of which record position has teh curent
focus.
Option Compare Database
Option Explicit
Dim ORDERRECORDS As Integer ' number of records in the recordset
Dim RecordsToMove As Integer ' number of records to advance
Const FORMRECORDS = 10 ' ' the number of viewable records
Private Sub NextPage_Click()
Dim targetForm As Form
Set targetForm =
Forms!sfrmOrder!sfrmOrderSubformTicket!sfrmOrderSubformTicketDetail.Form
ORDERRECORDS = targetForm.Recordset.RecordCount
If ORDERRECORDS > FORMRECORDS Then
If ORDERRECORDS - Me.LastRecord > FORMRECORDS Then
RecordsToMove = Me.LastRecord + FORMRECORDS - 1
Me.LastRecord = Me.LastRecord + FORMRECORDS - 1
else
RecordsToMove = Me.LastRecord + FORMRECORDS
Me.LastRecord = Me.LastRecord + FORMRECORDS
End If
Me.sfrmOrderSubformTicketDetail.SetFocus
DoCmd.GoToRecord , , acNext, RecordsToMove
End If
When I run this code, I get the following error:
Runtime 2105: You can't go to the specified record.
Any help?