Trying to set the top displayed record in a subreport

mdnuts

Registered User.
Local time
Today, 04:12
Joined
May 28, 2014
Messages
131
G'day all.

I have the following structure
- Form "frmTestResults - contains all specific information for a given AP number
- - Sub Report "rptAPNumber (not linked master/child) - continuous report just listing all of the "AP" numbers.

The user can select any of the AP numbers on the report and have it load the main form with all relevant details. What we'd like to do is when the main form is loaded - have that particular AP Number show up at the top of the report list.

Code:
DoCmd.SearchForRecord , , acFirst, "[AP_Acronym]=" & Forms!frmTestResults.AP_Acronym

Right now i have that in the report_current(), but I've tried it in the form_current() as well by setting focus to the report first. It does not error at all, just does not change the current view of the report. I thought it might have been because i have the report setting an order On Load - but removing that did not alter things at all.

Any thoughts? this seems simpler than it has been.
 
I wouldn't use a report. I would use a form to hold the list. If you are using a report in report view rather than print preview, there are no breaks. The whole report is one long scroll like a web page. So by putting the selected record at the "top" what does that mean? How can the report take record 45 and make it the first record of the report? What happens to the records that logically sort in front of it? With a form, you have a "window" that scrolls and so that allows you to put record 45 at the top of what is visible without having to resort the records.
 
I wouldn't use a report. I would use a form to hold the list. If you are using a report in report view rather than print preview, there are no breaks. The whole report is one long scroll like a web page. So by putting the selected record at the "top" what does that mean? How can the report take record 45 and make it the first record of the report? What happens to the records that logically sort in front of it? With a form, you have a "window" that scrolls and so that allows you to put record 45 at the top of what is visible without having to resort the records.
i was thinking about trying a form last night instead of a report.
 
as usual i way overthought this. After changing it from a subreport to a continuous subform I banged around on Lebans solution from a long time ago, several other attempts and finally:


In the subform i have
Code:
Public Sub refreshIT()
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[subFormFieldNameToSearchOn] = '" & Forms!<mainFormName>.<MainFormMatchingField> & "'"
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

I need to call this in 3 different spots. 1) when subform is clicked, 2) when prev button is clicked on main form, 3) when next btn is clicked on main form

on the SubForm
Code:
Private Sub AP_Acronym_Click()
  Call refreshIT
End Sub

and in my Prev & Next buttons on the main form
Code:
Private Sub btnNext_Click()
  Forms!<MainFormName>!<SubFormName>.Form.refreshIT
End Sub


It works fine, it'd be nice if the selection showed at the top of the continuous subform - but maybe something to look at another day.
 

Users who are viewing this thread

Back
Top Bottom