I've created a form with a listbox in Access 2002 SP2. Users can select an item from the listbox and click on a cmdbutton to run a simple query whose results appear in a MsgBox. That works great. Rather than return the results in a MsgBox, I'd like the results to be output'd to an RTF or a Word doc. Eventually, there will be several queries performed from this cmdButton and I'd like all the results to go to the same Word doc. I just can't figure out how to do this and I've really been banging my head on the wall. Here's the code I've got so far"
Private Sub CmdSummaryReport_Click()
Dim strFieldOpsID As String
Dim MonthlySummarySQL As String
Dim RS As DAO.Recordset
strFieldOpsID = List0.Value
MonthlySummarySQL = "SELECT COUNT(CorrectedValue) FROM Readings WHERE FieldOpsID = " & strFieldOpsID & " AND (CorrectedValue <= 5)"
Set RS = CurrentDb.OpenRecordset(MonthlySummarySQL)
' this part works
While Not RS.EOF
MsgBox "Number of Hours <= 5: " & RS.Fields(0).Value
'this part doesn't work and I may be going down the wrong path...
DoCmd.OutputTo acOutputTable, "Monthly Summary", acFormatRTF, "c:\Report.RTF", True