MS access compile error

Tanveer Uz Zamaan
Tanveer Uz Zamaan used Ask the Experts™
on
I have a problem regarding pdf report generation in ms access i have a code as
Option Compare Database

Private Sub Command2_Click()

    Dim bytz1 As Byte
   
    For bytz1 = 1 To 36
   
    Me.RecordSource = "SELECT Districts.ID, Districts.District FROM Districts WHERE (((Districts.ID)=" & bytz1 & "));"

    DoCmd.OutputTo acOutputReport, "MS datapack - landscape", acFormatPDF, "C:\Users\Lenovo\Desktop\PMU\" & Me.Text2.Value & ".pdf"


    Next bytz1

End Sub

Private Sub Detail_Click()

End Sub

when i run this code it gives error as compile error method or data member not found.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010

Commented:
Where is this code located?  Normally, simply changing the value of a RecordSource in a form will not affect the results of a report, unless that reports RecordSource refers to one or more controls on the form.

It would be helpful to know what error message you are receiving, and if you select the "debug" button on the error message popup, it should actually take you to the line of code which is causing the error.
Let suppose the report is OK.

You can save as a PDF or XPS file from a Microsoft Office system program only after you install an add-in.

Did you install the add-in? What Access version do you use?

More info
Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010

Commented:
@pcelba,

I believe 2007 was the last version that you actually had to install the PDF add-in for.  I believe all newer versions come with the PDF feature installed.

Dale

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial