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

VBA Report and Template Question

Status
Not open for further replies.

MIrizarry

Programmer
Aug 17, 2003
4
US
I am creating a report entirely in VBA using a blank report as a template.

I want to underline some, not all, of the detail lines based on the value of a field in the recordset.

Any help on how thiscan be done?
 
Use the Line method in your code...
If SomeExpr = True Then
Me.Line (0,Me.Detail.Height)-Step(Me.Width,0)
End If

Duane
MS Access MVP
 
I'm still a bit confused.

Here's my logic flow in VBA

Enter values into Form.
Press button which executes the following code:

Create Arrays
Create Tables
rpt.openreport(,Template)
rpt.CreateReportControl(...Header)
rpt.CreateReportControl(...Detail)
rpt.CreateReportControl(...Footer)
OpenReport rpt, Preview

In the table I have a column which flags a row as a special row. When the report is being generated as a preview, where do I add the code display a line for the special rows? Do I put it in the template, if so, where, or can I create a function when I generate the report code?

Sorry if I did not define the problem better earlier.

Thanks!

Mel
 
You would use my code in the On Format event of the detail section. This assumes that you have a bound control in your detail section that you can use to evaluate.

Duane
MS Access MVP
 
I put the code in the Format event of the detail section of the report template but nothing happens when I run the job. I put in a debug.print statement but nothing was printed.

Is the format event triggered if the report is used as a template?

Mel
 
If your report has a record source, the detail section's On Format event should run for each record.

What is your code look like in the On Format event of the detail section?

Duane
MS Access MVP
 
This is the code from the template:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Trim(Me.txtSortGroup) = "9" Then
Me.Line (0, Me.Detail.Height)-Step(Me.Width, 0)
End If
Debug.Print "Report Detail"
End Sub

Interestingly I created the a control called txtSortGroup in the report. Another control is being created in the VBA code which is also called txtSortGroup. When I run the job I do not get an error of a duplicate control name being created. This leads me to believe that the controls and code attaced to them are not used when using the report as a template for the CreateReport() function.

Mel
 
Can you just place a generic invisible control on your report template. Then assign a control source when the report opens?

Duane
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top