1

I get an error for my code:

compile error: Expected: =

DoCmd.OutputTo (acOutputReport, _
    ReportName & " " & Load, _
    acFormatPDF, _
    "\\drive\Reports\" & ReportName & " " & Load & " " & Year(Date) & Month(Date) & Day(Date)& ".pdf")

I have Access front-end and SQL-Server backend.

What do I need to do to fix this? I am still a beginner with VBA.

1 Answer 1

3

You must call Sub procedures without parameter parentheses ( ) in VBA.

DoCmd.OutputTo acOutputReport, _
    ReportName & " " & MyLoad, _
    acFormatPDF, _
    "\\drive\Reports\" & ReportName & " " & MyLoad & " " & _
        Year(Date) & Month(Date) & Day(Date) & ".pdf"

Also Load is a reserved word in VBA. It is Sub Load(Object As Object). Use another identifier.


The compile error "Expected: =" may seem awkward, but it makes sense, since parentheses are used for Function calls. I.e., VBA is expecting something like this

x = MyFunc(...)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.