Hi guys,
I have to migrate the following function, among other things this function opens a report in design mode and sets the report to a report variable to change some paper properties, the function works perfect in adp format but when I change it to ade the error 7802 triggers. I did some redn found I am not allow to open a report in design mode when using ade's so how Can I perform the tasks in this format? I am new in access and a simple solution would be much appreciated.
Thanks a lot for reading my post.
Public Sub PrintLabel(aLabelQuantity As String)
On Error GoTo HandleErrors
Dim rpt As Report
Dim dm As clsDevMode
Dim pl As clsPrintLayout
Dim strParameters As String
Const conTwipsPerCentimetre As Long = 567
Dim dm2 As clsDevModeDefaultProperties
' Stop the echo
DoCmd.Echo False
strParameters = gobjPerson.gstrNumber & ";" & mstrLabelName
SetReportParameters "rptWwCustomizedLabels", strParameters
' Change 003 YM Open the report in design mode not compatible with ade format
'DoCmd.OpenReport "rptWwCustomizedLabels", acViewDesign
' Get reference to the selected label report
Set rpt = Reports("rptWwCustomizedLabels")
rpt.PrtDevMode = Nothing
Set dm = New clsDevMode
Set dm.Object = rpt
' Set the paper properties
dm.PaperSize = DMPAPER_USER
dm.PaperLength = mintHeight * 10 + 3
dm.PaperWidth = mintWidth * 10 + 10
dm.TrueTypeOption = DMTT_DOWNLOAD
dm.Save
Set pl = New clsPrintLayout
Set pl.Object = rpt
' Set the paper properties
pl.Left = 0.009 * conTwipsPerCentimetre
pl.Right = 0.009 * conTwipsPerCentimetre
pl.Top = 0.009 * conTwipsPerCentimetre
pl.Bottom = 0.007 * conTwipsPerCentimetre
pl.ItemsAcross = 1
pl.ItemLayout = mloHorizontal
pl.DefaultSize = mdsUseWidthAndHeight
pl.Width = mintWidth / 10 * conTwipsPerCentimetre
pl.Height = mintHeight / 10 * conTwipsPerCentimetre
pl.DataOnly = False
rpt.Section(acDetail).Height = mintHeight / 10 * conTwipsPerCentimetre
rpt.Width = mintWidth / 10 * conTwipsPerCentimetre + 10
'Print the report
'DoCmd.PrintOut
' Free variables
Set pl = Nothing
Set dm = Nothing
Set rpt = Nothing
' Close report Change 001 YM
DoCmd.Close acReport, "rptWwCustomizedLabels", acSaveYes
'Set echo as it was
DoCmd.Echo True
ExitHere:
Exit Sub
HandleErrors:
'$Error
HandleError Err.Number, Err.Description '$Error
'$Error
End Sub