Accessing Recordset Data from Report Detail Section Using Format E

  • Thread starter Thread starter keith
  • Start date Start date
K

keith

I'm using the Format event to show/hide controls in the detail section of my
report. In order to do this, I need to access data that is in the report
record source but is not used in any control being displayed in the detail
section of the report. In forms, the RecordsetClone property provides this
capability. I could use hidden controls to get at this data, but they would
add a significant overhead and clutter things up. Any thoughts?

Thank you.
 
I'm using the Format event to show/hide controls in the detail section of my
report. In order to do this, I need to access data that is in the report
record source but is not used in any control being displayed in the detail
section of the report. In forms, the RecordsetClone property provides this
capability. I could use hidden controls to get at this data, but they would
add a significant overhead and clutter things up. Any thoughts?

Thank you.

Just how would not visible controls in the detail section create
overhead or clutter?
I think setting a control to visible or not visible using a not
visible control's value is fine.

Code the Detail Format event:
Me.[ControlName].Visible = Me.[HiddenControlName] = Some Value

If the control is not visible, you can simply stack one on top of
another somewhere.
 
Thank you for your response. Hidden controls are always a viable solution.
Unfortunately, in my report, I have almost 50 visible controls on the detail
line with the report sized to Legal-Landscape. This makes hidden controls
very hard to deal with. I was considering putting hidden controls in a
second row and then using code to force the row height to show only the first
row using code. However, I wanted to explore getting at the underlying data
first.
 
Thank you for your response. Hidden controls are always a viable solution.
Unfortunately, in my report, I have almost 50 visible controls on the detail
line with the report sized to Legal-Landscape paper and 5-point Arial font.
This makes hidden controls very hard to deal with. I was considering putting
hidden controls in a second row and then using code to force the row height
to show only the first row using code. However, I wanted to explore getting
at the underlying data first.

Also, when I've put too many controls on a report, it has crashed Access and
made the report non-recoverable. I've also run into this with forms and have
had to come up with some exotic methods (such as dynamic subforms) to deal
with this.

fredg said:
I'm using the Format event to show/hide controls in the detail section of my
report. In order to do this, I need to access data that is in the report
record source but is not used in any control being displayed in the detail
section of the report. In forms, the RecordsetClone property provides this
capability. I could use hidden controls to get at this data, but they would
add a significant overhead and clutter things up. Any thoughts?

Thank you.

Just how would not visible controls in the detail section create
overhead or clutter?
I think setting a control to visible or not visible using a not
visible control's value is fine.

Code the Detail Format event:
Me.[ControlName].Visible = Me.[HiddenControlName] = Some Value

If the control is not visible, you can simply stack one on top of
another somewhere.
 
I wanted to pass on that I found a way to access the underlying recordset for
a report. The answer lies in the Help and Support Article 287437 entitled
"You may receive the 'Run-time error 2593' ..." which talks about a known
problem in MSAccess. Basically, here's what I did:

In the code for the report, I did the following:

1. In the Declarations section of the module, I declared a variable to hold
a recordset:

Private m_SourceData as recordset

2. In the Report_Open even, I added the following code:

Set m_SourceData = CurrentDb.OpenRecordset(Me.recordSource, dbOpenDynaset)
Me.recordSource = m_SourceData.Name

3. In the Report_Close event, I added the following code:

m_SourceData.Close

4. In the Detail_Format event, I had to add code to "sync" the recordset
with the data in the report. To do this, I added the following code:

m_SourceData.FindFirst "UniqueID='" & Me.txtUniqueID & "'"

where txtUniqueID is a bound textbox which holds the unique ID for the row
I'm processing. I have to do it this way as the recordsource is a query.
 
Back
Top