docmd

steve111

Registered User.
Local time
Today, 18:54
Joined
Jan 30, 2014
Messages
429
hi,

I want to try and see if this will put a report into the folder c:\users\user\documents\invoice\

DoCmd.OutputTo acOutputReport, "PDFInv", acFormatPDF, "C:\USERS\USER\DOCUMENTS"\invoice & Me. orderno & ".pdf"

the problem if this is correct is I don't know where to put it and how to make it work . I assume the report has to be open also ,


any help appreciated

steve
 
Put in a VBA procedure and run the procedure.

For example you could create a button and put it in the Click event procedure of that button.
 
you also have a problem with your code

"C:\USERS\USER\DOCUMENTS"\invoice &

should be

"C:\USERS\USER\DOCUMENTS\invoice" &
 
no - the report does not need to be open first.

the command will prepare and export the report automatically.
 
hi,

I created a button and but this into into on click DoCmd.OutputTo acOutputReport, "PDFInv", acFormatPDF, "C:\USERS\USER\DOCUMENTS\invoice" & Me.Invoice No & ".pdf" but I get an error that says
compile error
syntax error

and my code is in red

steve
 
Last edited:
you are using spaces in your field/control names

Me.Invoice No

You need to substitute an underscore (_) for the space

Better still, don't use spaces in table and field names, then you won't get this problem
 
if you have a space you need

[Me].[Invoice No]

or just

[Invoice No]

you need square braces when you have a space in an idenitfier
 
hi ,

I am now getting another error
method or data member not found


the macro button under e-mail customer is what I I press to run the vba
I have attached a file to view if it helps
record 2 in the form is the one with the invoice number in it
and the invoice number is 1



thanks
steve
 

Attachments

hi ,

with the brackets in I get an error
Microsoft access cannot find the field !1! referred to in you expression

steve
 
this is how I got it to work


Code:
DoCmd.OutputTo acOutputReport, "Invoice report", acFormatPDF, "C:\Users\User\Documents" & "\" & Me.Customer.Column(1) & " " & Me.InvoiceNumber & ".pdf", True
or


DoCmd.OutputTo acOutputReport, "Invoice report", acFormatPDF, "C:\Users\User\Documents" & "\" & "invoice number" & " " & Me.InvoiceNumber & ".pdf", True

thanks to all
 

Users who are viewing this thread

Back
Top Bottom