code output report rtf
RH

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » Code to Output a report as RTF

Code to Output a report as RTF

resolvedResolved · Urgent Priority · Version 2003

Nicola has attended:
Access Introduction course
Access Intermediate course
Access Advanced course
Access VBA course

Code to Output a report as RTF

Hi,

I am editing a database that was created by a previous member of staff.

I need to have a command button when clicked output a report in RTF format and save it in a form, I have the code and it keeps displaying a message that it cannot save to the specified location, but there is already code within the system that saves other reports to that location.

Private Sub cmdQ4_Click()

Dim rpt As String
Dim strDest As String

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

create_a:

rpt = "rpt:Q4"
strDest = "I:\landchar\searches\NEW RTF" & [Forms]![frm:detailsInput]![Official Search Number] & ".rtf"

DoCmd.OutputTo acOutputReport, rpt, acFormatRTF, strDest


End Sub

I have tried the debugger, but cannot work out how to make it work!
This system is supposed to be running after the bank holiday and I cannot see it happening at the moment

Any help or advice would be greatly appreciated.

Nikki

RE: Code to Output a report as RTF

Hi Nicola thanks for your query. The first element of your concatenated string strDest is:

"I:\landchar\searches\NEW RTF"

...and you're going to need another backslash after NEW RTF otherwise the rest of the text will be bolted straight onto that folder name, thereby pointing the computer at a destination that doesn't exist and causing the error you are encountering. Try putting the backslash in and see if it helps.

All the best,

Anthony

RE: Code to Output a report as RTF

Anthony,

Thanks, that worked great, the only problem I have with it now is that it is reportng every entry in the database (at the moment its only 100 or so).

I have gone over the code and cannot see a way to make it only report the current record.

Thanks

Nikki

RE: Code to Output a report as RTF

Hi Nikki, difficult to advise you on this one without seeing the source files, but you might need to put any extra line of code in to go to the last record and report on only that. What that code looks like depends a lot on the nature of your database, but you might want to run a query, extract the latest record and run your VBA on that.

Hope this helps,

Anthony

Mon 17 May 2010: Automatically marked as resolved.

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Access tip:

Using the Quick Access Toolbar in Access 2010

The Quick Access Toolbar is included in virtually every Office product, including Outlook 2010, Word 2010, Excel 2010, and PowerPoint 2010.

You will find the Quick Access Toolbar in the top-left side of the window. To begin, click the Customize button (it's the little black arrow at the end of the toolbar).

Simply click the commands you want to include.

Virtually any command can be added to the Quick Access Toolbar. Click the More Commands option and a new window will open from where you can browse the commands including those not on the ribbon.

View all Access hints and tips


Server loaded in 0.05 secs.