Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

code output report rtf

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

ResolvedVersion 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:

Hiding rows and columns

To hide a column or row in Access, you need to minimise the column or row. This can be done by placing your mouse on the right edge of a column, wait for the mouse to change to a double aroow and then drag to minimise the column

View all Access hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.