Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listbox values appear in Access report but not in word doc version

Status
Not open for further replies.

Pack10

Programmer
Feb 3, 2010
495
US
I am building a routine that formats a letter as an Access report then creates a word document from it.
There are a few fields where the user enters Name, Company and Address. There is a listbox that is populated with info for the letter. They click a button and the report opens (letter).
Everything is fine in the report. When word opens the access report is passed to word and a word doc is created. All the textboxes from the report are correct in the word doc, however the values from the listbox are not in the word doc (but appear in the access report). How can I get that info to the word doc.
I am not sure what I need to do.

Heres the code....

strFileName = Me.txtRecipient & Month(Date) & Day(Date)
Call ExportToRTF("rptLetter", "G:\Docs\" & strFileName, "Report")


Sub ExportToRTF(strName As String, strPath As String, Optional strItem As String = "Report")

Dim intType As Integer
Dim strRtFile As String
Dim wdApp As Word.application

intType = acReport

Set wdApp = CreateObject("Word.Application")

' select the object in the database window
DoCmd.SelectObject intType, strName, True

' output the document to word
DoCmd.RunCommand acCmdOutputToRTF

' find RTF name and path
strRtFile = wdApp.ActiveDocument.FullName

' Save the document as a word document in the required place

wdApp.ActiveDocument.SaveAs strPath, wdFormatDocument

'wdApp.Quit

Set wdApp = Nothing

'delete the RTF file since it's not needed
Kill strRtFile


End Sub
 
Are you expecting a listbox control to be in your RTF document? Ain't going to happen.

I'm not sure why the listbox appearance is necessary. Can you provide some justification why a list box is even on a report?

Duane
Hook'D on Access
MS Access MVP
 
Thanks for pointing that out. I changed to a subform and I got the routine working. When I have a minute, there is something that I don't understand, I will add to this post.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top