Carmen,
You should be able to put the code in a method of the form that runs the report, and call it like below from the report. Whether or not that is the best solution for you, I don't know :)
>>Hi Sergey
> Can the code for assigning the invoice number be stored in a method on the current form, or can it be stored with the report, or is it standalone code that is part of the project, the reason I'm asking is that the form from which the invoice report is printed has to know the invoice number to include it in the A/R entries which occur after the invoice has been printed.
>
>Regards,
>Carmen
>
>Not directly but you can call your function that assigns invoce number from the Title band "On Entry".
>>WEXISTS("Printing...") AND thisform.AssignInvoiceNumber()
>>...
>>Function AssignInvoiceNumber()
>>* Generate/get invoice number
>>...
>>RETURN .T.
Steve Gibson