export form to word

N

nicolascaprais

Hello, the code below allows me to open on a separate form one entry of
a table with the use of cascading filters.

Private Sub Commande31_Click()DoCmd.OpenReport "rptCordisDetails", A_PREVIEWDim strSQL2 As StringDim intCounter As Integer 'Build SQL String For intCounter = 1 To 2 If Me("Filter" & intCounter) <> "" Then strSQL2 = strSQL2 & "[" & Me("Filter" & intCounter).Tag & "] " & " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) & " And " Else End If Next 'special provision for reliability If Me("Filter" & intCounter) <> "" Then strSQL2 = strSQL2 & "[" & Me("Filter" & intCounter).Tag & "] " & Me("Filter" & intCounter) & " And " End If If strSQL2 <> "" Then 'Strip Last " And " strSQL2 = left(strSQL2, (Len(strSQL2) - 5)) 'Set the Filter property Reports![rptCordisDetails].Filter = strSQL2 Reports![rptCordisDetails].FilterOn = True Else Reports![rptCordisDetails].FilterOn = False End IfEnd Sub



How could I have a similar code to this one, which would export the same
result to a word document, instead of opening it in a report like above?



Thanks

nico
 
K

Kevin

Checkout the sendobject command in help. send the report
to word.

Hope this helps!

Kevin
-----Original Message-----

Hello, the code below allows me to open on a separate form one entry of
a table with the use of cascading filters.


Private Sub Commande31_Click()
DoCmd.OpenReport "rptCordisDetails", A_PREVIEW
Dim strSQL2 As String
Dim intCounter As Integer

'Build SQL String
For intCounter = 1 To 2
If Me("Filter" & intCounter) <> "" Then
strSQL2 = strSQL2 & "[" & Me("Filter" &
intCounter).Tag & "] " & " = " & Chr(34) & Me("Filter" &
intCounter) & Chr(34) & " And "
Else

End If
Next

'special provision for reliability

If Me("Filter" & intCounter) <> "" Then
strSQL2 = strSQL2 & "[" & Me("Filter" & intCounter).Tag
& "] " & Me("Filter" & intCounter) & " And "
End If

If strSQL2 <> "" Then
'Strip Last " And "
strSQL2 = left(strSQL2, (Len(strSQL2) - 5))
'Set the Filter property
Reports![rptCordisDetails].Filter = strSQL2
Reports![rptCordisDetails].FilterOn = True

Else
Reports![rptCordisDetails].FilterOn = False
End If

End Sub



How could I have a similar code to this one, which would export the same
result to a word document, instead of opening it in a report like above?



Thanks

nico
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top