Select Query Results Output To Word

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a Select Query that gives me the desired results.

I know I can click on Office Links and output the query results to Word -
"publish it with ms word"

I think that the button uses DoCmd.RunCommand acCmdOutput to RTF

but I'm not certain how to incorporate this into a bit of programming code
that will automatically do that step without having to click Office Links and
select the Publish It With MS Word command option. Any help?
 
Thanks Duane,

Your applet looks awesome...It will take me some time to study
it...Initially it looks like a lot more than I was looking for...but I can
see that studying it will be a great learning experience...Can you tell me if
I was thinking along the right lines?...in terms of the basic
approach...Right now what I'm doing is selecting the datasheet view of the
query results along with the field names and copying it into an open Word
document, then saving it...I was hoping to be able to do that like from just
a one button response from the user.
 
Take a look at the code behind the button that sends the query results to
Word. There is a big Select Case section of code to handle the various
"destinations".
 
Is that the Private Sub cmdSend_Click()

which starts with...

' Parameters:
'============================================================
On Error GoTo cmdSend_Click_Err
Dim strErrMsg As String 'For Error Handling
Dim strFile As String
Dim strSendTo As String
Dim varRet
If Me.grpSendTo <> 1 And Len(Me.txtFileName & "") = 0 Then
MsgBox "You must provide a file name.", vbOKOnly + vbInformation, "No
File Name"
Me.txtFileName.SetFocus
Exit Sub
End If

Select Case Me.grpSendTo...
Cases...
 
Yes the grpSendTo value would be "2"

Select Case Me.grpSendTo
Case 1
DoCmd.OpenQuery "myquery", acViewPreview
Exit Sub
Case 2
strSendTo = acFormatRTF
'...
DoCmd.OutputTo acOutputQuery, "myquery", strSendTo, Me.txtFileName,
Me.chkAutoStart
 
Back
Top