PC Review


Reply
Thread Tools Rate Thread

Calling report/setting Recordsource

 
 
Joao
Guest
Posts: n/a
 
      7th Jul 2008
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?
 
Reply With Quote
 
 
 
 
Paolo
Guest
Posts: n/a
 
      7th Jul 2008
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?

 
Reply With Quote
 
Joao
Guest
Posts: n/a
 
      7th Jul 2008
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?

 
Reply With Quote
 
Paolo
Guest
Posts: n/a
 
      7th Jul 2008
Well Joao,
if the source table remains the same and you wanna change the parameters you
can pass them in the docmd.openreport "yourreport,,whereconditions
If you need to change also the table/query on which is based the report you
have to change it in the open event of the report as I said before.

Regards Paolo

"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?

 
Reply With Quote
 
Joao
Guest
Posts: n/a
 
      7th Jul 2008
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?

 
Reply With Quote
 
Paolo
Guest
Posts: n/a
 
      8th Jul 2008
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?

 
Reply With Quote
 
Joao
Guest
Posts: n/a
 
      8th Jul 2008
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?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting a report's recordsource? Maury Markowitz Microsoft Access 3 11th Dec 2007 06:54 PM
Calling a Function (Setting a RecordSource) =?Utf-8?B?ZGxlcmg=?= Microsoft Access VBA Modules 5 9th Feb 2006 04:45 PM
setting a report's recordsource... Brad Pears Microsoft Access Form Coding 3 5th Jan 2006 05:00 PM
Setting Recordsource in report Vikki Microsoft Access Reports 3 19th May 2004 05:16 AM
Setting Report Recordsource Simon Harris Microsoft Access 6 15th Nov 2003 07:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:23 PM.