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

Begin printing at specific line on page

Status
Not open for further replies.

THWatson

Technical User
Apr 25, 2000
2,601
CA
Using Access 2003

A form opens and the user selects a name for which to print Memorial Donations on a booklet page. There may or may not already be entries printed on the page, so the user is asked to determine how many inches from the top of the page to begin printing. This is done through a pop-up form, frmInputBox, and the user enters the appropriate #(8 = 1 inch).

Below is code that always worked with Access 2000. However, this does not work since we switched to Access 2003.

The OLE boxes are either printed or not printed depending upon whether it's a new page upon which printing starts.

Text25 is data - name for whom donations are made etc. - that comes from the form that calls the report.

MyInt is a non-visible tiny text box in the report header.

MySpc is the value that comes from frmInputBox.

Code:
Option Compare Database
Option Explicit
Public MySpc As String
Public myInt As Integer

Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer)
If Me.Page = 1 And Me.txtShowInt <= 2 Then

Me.OLEUnbound1.Visible = True
Else
Me.OLEUnbound1.Visible = False
End If

If Me.Page > 1 Then
Me.OLEUnbound1.Visible = True
End If
End Sub
'- - - - -
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)

If Me.Page = 1 Then
Me.Text25.Visible = False
Else
Me.Text25.Visible = True
End If

If Me.Page = 1 And Me.txtShowInt <= 2 Then

Me.OLEUnbound0.Visible = True
Me.Label2.Visible = True
Else
Me.OLEUnbound0.Visible = False
Me.Label2.Visible = False
End If

If Me.Page > 1 Then
Me.OLEUnbound0.Visible = True
Me.Label2.Visible = True
End If
End Sub
'- - - - -

Private Sub Report_Close()
DoCmd.Close acForm, "frmInputBox"

Dim i As Integer
 For i = 0 To Forms!frmMemorialBook!List2.ListCount - 1
  Forms!frmMemorialBook!List2.Selected(i) = False
 Next i
Forms!frmMemorialBook!txtSelected = Null
Forms!frmMemorialBook!Text19 = Null
Forms!frmMemorialBook!txtFund = Null
End Sub
'- - - - -
Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "frmInputBox", WindowMode:=acDialog

End Sub
'- - - - -
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)

Dim myInt As Integer
   On Error GoTo ReportHeader_Format_Error

MySpc = ""
myInt = 0

If Me.Page < 2 Then
For myInt = 2 To Forms!frmInputBox!txtResponse
MySpc = MySpc & vbNewLine '& myInt
Me.txtMySpc = MySpc

Next myInt
Me.txtShowInt = myInt
End If

   On Error GoTo 0
   Exit Sub

ReportHeader_Format_Error:
    If Err.Number = 13 Then
    Me.txtShowInt = 0
    Exit Sub
    Else
    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure ReportHeader_Format of VBA Document Report_rptMemTest"
    End If
End Sub

I have placed the "- - - - -" lines in the above just for ease of showing where the various code pieces start and end.

There is no error when the code runs. It just doesn't do anything. Irrespective of what the value entered in frmInputBox there is no effect.

Can anyone spot how to either fix this, or show a better method for achieving the desired result?

Thanks.

Tom
 
I found the problem.

I had made the text box txtMySpc invisible. If I switch that back to Visible it works.

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top