I may be trying the impossible. I'm trying to print multiple records on preprinted forms. However, each record may be on different forms. There will always be at least to different formats. So what I have done is to create a table that specifies the width, height, top and left properties for each control based on the form type needed by a specific record. At the bottom of the Detail section of the report, I have a page break so that each record will be on its own page. So I have my code that loops through the controls and sets the various size/position properties.
Now my problem is in which event to I call this. I had put it in the report's On_Current event, but I have to actually click on each record for this to run. Even in print preview while cycling through the pages doesn't trigger it. Also, as soon as it tries to change the Width property, the control becomes invisible. I thought maybe a repaint was needed, but I can't find a command for that.
I had thought of having a different report for each form and then just looping through the records calling each report as needed, but then either I would have to use the default printer or be asked which printer I want to use for every single record. Not what I'm wanting to happen.
Code:
Dim db As DAO.Database
Dim strControls As String
Dim rstControls As DAO.Recordset
Set db = CurrentDb
strControls = "SELECT ControlName, Visible, Width, Height, Top, Left, FontSize, TextAlign " & _
"FROM TicketSpecs WHERE TicketTypeID_fk = " & Me.txtTicketType
Set rstControls = db.OpenRecordset(strControls, dbOpenDynaset)
With rstControls
Do While Not .EOF
With Me.Controls(!ControlName)
If rstControls!Visible Then
.Visible = True
.Width = rstControls!Width
.Height = rstControls!Height
.Top = rstControls!Top
.Left = rstControls!Left
.FontSize = rstControls!FontSize
.TextAlign = rstControls!TextAlign
Else
.Visible = False
End If
End With
.MoveNext
Loop
End With
Set db = Nothing
rstControls.Close
Set rstControls = Nothing
I had thought of having a different report for each form and then just looping through the records calling each report as needed, but then either I would have to use the default printer or be asked which printer I want to use for every single record. Not what I'm wanting to happen.
Comment