RESOLUTION
Instead of using the line control to create a line on a form or report, use
a rectangle control or the borders of a text box.
The following sample code demonstrates how to open all the reports in a
database and then replace all the lines controls in the reports with
rectangle controls.
NOTE: In the following sample code, an underscore (_) at the end of a line
is used as a line-continuation character. Remove the underscore from the
end of the line when re-creating this code in Access Basic.
Option Compare Database ' Use database order for string comparisons.
Option Explicit
Sub ChgLinToRect (Rptname As String)
' Opens the report and changes lines to rectangles.
Dim i, numctrls
Dim rpt As Report
Dim newrect As Control
DoCmd OpenReport Rptname, A_DESIGN
Set rpt = Reports(Rptname)
numctrls = rpt.count
For i = 0 To numctrls - 1
If IsLineControl(rpt(i)) Then
' If it is a line control then create a new rectangle
' with properties like the line.
Set newrect = CreateReportControl(rpt.name, 101, _
rpt(i).section, "", "", rpt(i).left, rpt(i).top, _
rpt(i).width, rpt(i).height)
newrect.BorderStyle = rpt(i).BorderStyle
newrect.BorderColor = rpt(i).BorderColor
newrect.BorderWidth = rpt(i).BorderWidth
newrect.BorderLineStyle = rpt(i).BorderLineStyle
newrect.SpecialEffect = 0
' Delete the line.
DeleteReportControl Rptname, rpt(i).name
' Decrease counters by one.
i = i - 1
numctrls = numctrls - 1
End If
Next i
DoCmd DoMenuItem 7, 0, 2
DoCmd Close
End Sub
Function DoAllReps ()
' This function loops through all reports, changing lines to
' rectangles.
Dim db As Database
Dim i
Set db = DBEngine.Workspaces(0).Databases(0)
For i = 0 To db.Containers("Reports").Documents.Count - 1
ChgLinToRect (db.Containers("Reports").Documents(i).Name)
Next i
End Function
Function IsLineControl (Ctl As Control)
' This function tests to see if a control is a line control.
Dim x
On Error Resume Next
x = Ctl.lineslant
IsLineControl = (Err = 0)
End Function
To run this code, call the DoAllReps() function in a module's Immediate
window by typing the following line and then pressing ENTER:
?DoAllReps()
NOTE: There will be a great deal of screen activity caused by the property
sheets and windows opening and closing.