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!

Report printing wrong

Status
Not open for further replies.

Lewy

Technical User
Nov 16, 2001
170
GB
I have a report that overprints individual letters onto a pre printed form - much like an English passport application form. The individual letters HAVE to be within the small boxes otherwise the form gets rejected by our NHS. I have spent hours getting the letters to line up correctly only to find a week later the positions have moved and I have to redo the report. Can it be Access that is at fault in changeing the parameters within onLoad event, or would there be a better way to achieve the correct result?

I am using code along the lines of, to position each letter:

For C2 = 1 To 22
Controls("F" & C2) = UCase(Mid([FName], (C2), 1)) 'FirstName
Controls("F" & C2).Top = 1.15 * TwipsPerCM
Controls("F" & C2).Left = (6.6 + (C2 * 0.453)) * TwipsPerCM
Next

As you can see, I take the field value, loop through separating the string into individual letters and then printing it in the set position.

Any thoughts or help will be much appreciated.

Thanks,

Lewy

 
Which event is the code located in ie: On Format or On Print of which report section?

I have typically used the .Print method to print single characters. You can use CurrentX and CurrentY to set the top left

Code:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
    Dim intI As Integer
    Dim lngTop As Long
    Dim lngLeft As Long
    Dim dblSpacing As Double
    lngTop = Me.linTopLeft.Top
    lngLeft = Me.linTopLeft.Left
    dblSpacing = 1440 / 4 [COLOR=#A40000][highlight #FCE94F]'1/4"[/highlight][/color]
    [COLOR=#A40000][highlight #FCE94F]' you can also set the font and font size here[/highlight][/color]
    For intI = 1 To Len(Me.txtFirstName)
        Me.CurrentX = lngLeft + (intI - 1) * dblSpacing
        Me.CurrentY = lngTop
        Me.Print Mid(Me.txtFirstName, intI, 1)
    Next
End Sub

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
The code is in the OnLoad event rather than in the OnPrint. I have just started experimenting with putting code in the OnPrint event. However, I need to have a combination of the 2 events as some of the overprinting is a simple 'X' that is either visible or invisible dependent upon a field value. I will have a play with the above code and see if I can simplyfy things. Many thanks, Lewy
 
The code should always be in the On Format or On Print event of the section containing the controls/print.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Thanks Duane, I will move the code to the On format event to begin with and see how it prints. Trouble is I am doing the coding in any spare time I have at work which can take a long time to get done.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top