VBA - for report footer field properties

M

MVP - WannaB

Hello and thank you for any and all help provided.
I received the code below from this site previously, I‘ve added to it and it
currently works fine, but I need to include one more setting, such as Page
Centering from left to right. How can I obtain the page width of each
report, I could then divide by 2 and subtract the standard width of the field
that I am trying to center.
SO my question how can I obtain the page width of each report? AND Move
the field after it has already been created?
ALSO – Is there any other purpose to the “For IngColumn = ……†other then I
had previously used that section to test only one report?

Here is the code I am currently working with. “Reports†is a table where I
keep a list of Reports.

Public Sub SetFontOfFooterCONFIDENTIAL()
Dim db As DAO.Database
Dim doc As Variant
Dim ctl As Control
Dim rst As DAO.Recordset
Dim lngColumn As Long
Set db = CurrentDb
Set rst = db.OpenRecordset("Reports", dbOpenDynaset, dbReadOnly)

If rst.EOF = False And rst.EOF = False Then
Do While rst.EOF = False
For lngColumn = 0 To rst.Fields.Count - 1
doc = rst.Fields(lngColumn).Value
' If doc <> "rEconomy" Then GoTo CloseReport
Next lngColumn
DoCmd.OpenReport doc, acViewDesign ', , , acHidden
On Error GoTo NoFooter
Application.CreateReportControl doc, acLabel, acPageFooter, , _
"Customer Confidential", 1440 * 3.6, 1440 * 0.2, 2880, 1440
For Each ctl In Reports(doc).Section(4).Controls
If TypeOf ctl Is Label Then
If ctl.Caption = "Customer Confidential" Then
ctl.FontSize = 8
ctl.ForeColor = 0
ctl.FontWeight = 0
ctl.SizeToFit
Else
ctl.Top = 0
End If
ElseIf TypeOf ctl Is TextBox Then
ctl.Top = 0
End If
Next ctl
CloseReport:
DoCmd.Close acReport, doc ', acSaveYes
rst.MoveNext
Loop
End If

Exit_Sub:
Set db = CurrentDb
Exit Sub
NoFooter:
MsgBox Error$
Resume CloseReport
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top