Robin,
Sorry, I overlooked the fact that you will now need to pass
the ID to the function when you call it as the Function is
in a Global Module after the conversion. Modify the first
line of the Function from...
Function macPrintIndividualReport()
to...
Function macPrintIndividualReport(lngID as Long)
This will allow us to pass the ID in as text. Now modify
this section of the OutputTo line to replace the
Me![YourIDField]] to lngID...
DoCmd.OutputTo acReport, "rptIndividualRecord",
"RichTextFormat(*.rtf)", "D:\###\" & Me![YourIDField] &
"IndividualReport.RTF", True, "", 0
to...
DoCmd.OutputTo acReport, "rptIndividualRecord",
"RichTextFormat(*.rtf)", "D:\###\" & lngID &
"IndividualReport.RTF", True, "", 0
Now on your command button, we will need to call the
function in a way that we can pass the ID to it. In the
OnClick event line type in the following...
=macPrintIndividualReport([ID]
It will now pick up the ID from the form and pass it to the
function for processing.
--
Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
Robin Chapple said:
Gary,
It is beginning to make sense.
My ID field is [ID]. Very imaginative. <G>
I have made the function but when I compile I get an error message:
" Invalid use of Me Keyword "
What have I done wrong.
Robin
Robin,
Good job getting the code out. There are some critical
details that I don't have from you so you may have to do
some substitution on the names, but you should get the gist
I think. First we need to find the ID from the form that is
calling this and then 'concantenate' it into the report
name. If all of what you have is working fine, then this
would be the modification using the Me![YourIDField] to poke
the ID in. Of course, you will need to change it to your
field name...
Function macPrintIndividualReport()
On Error GoTo macPrintIndividualReport_Err
DoCmd.SetWarnings False
DoCmd.OutputTo acReport, "rptIndividualRecord",
"RichTextFormat(*.rtf)", "D:\###\" & Me![YourIDField] &
"IndividualReport.RTF", True, "", 0
DoCmd.SetWarnings True
macPrintIndividualReport_Exit:
Exit Function
macPrintIndividualReport_Err:
MsgBox Error$
Resume macPrintIndividualReport_Exit
End Function