Paolo, on the contrary, it prints everytime, but I found the simple solution:
It works like this:
DoCmd.OpenReport "ReportName", acPreview
Thanks anyway.
"Paolo" wrote:
> It doesn't print everytime you call it? So it doesn't work very well!
> If you post the code I can try to understand why!
>
> "Joao" wrote:
>
> > It worked Paolo! The only problem now is that I don't the report printed
> > everytime I call it!!!!
> >
> > "Joao" wrote:
> >
> > > Thanks Paolo, i will try your tip. That simple SQL was just an example... The
> > > SQL I intend to put dinamically is much more complex.
> > >
> > > "Paolo" wrote:
> > >
> > > > Hi Joao,
> > > > actually to manipulate the recordsource of a report the report must be
> > > > already open and in your case you first assign the recordsource to something
> > > > that still doesn't exist and then you open it.
> > > > To make it work you must first open the report with the docmd.openreport
> > > > command and then you can assign the recordsource in the on open event of the
> > > > report.
> > > > I don't understand why you don't assign the recordsource in design mode of
> > > > the report, 'cause if you use something to filter I can understand the
> > > > meaning to assign the recordsource dynamically but in this case you assign
> > > > just a table as recordsource and so you can do it at design mode.
> > > >
> > > > HTH Paolo
> > > >
> > > > "Joao" wrote:
> > > >
> > > > > I want to open a Report using this:
> > > > >
> > > > > SQLString = "Select * from table"
> > > > >
> > > > > Code:
> > > > > Reports!Report1.RecordSource = SQLString
> > > > > DoCmd.OpenReport "Report1", acViewNormal, , , acWindowNormal
> > > > >
> > > > > The error says the report name is misspelled or doesn't exist...
> > > > > I am sure my report is named Report1...
> > > > > Anyone? Other solution?
|