Subject Re: report
From Charlie <tm@tc.com>
Date Sun, 09 Feb 2025 15:05:28 -0500
Newsgroups dbase.getting-started

Thanks so much.  Took me three days but found out I asked the wrong question.  It wasn't the database, it was a simple coding error.  Glad that is over!!!

Mervyn Bick Wrote:

> On 2025/02/06 22:11, Charlie wrote:
> > I have a report that id like to use with a different database but the same tables. (located in the different database.  I tried changing in the source code by changing the database name and database reference in the tables.  Did not work.  Started to cut the old tables but that screwed everything up.  Is there an easy way to do this or do I have to bite the bullet and make the report from scratch?  Thanks much.
>
> There is probably more than one way to do this but here's one scenario.
>
> In the report, create two database objects, each pointing to it's own
> database, and set the active property of each database object true.
>
> In the report, add a text object to the pagetemplate that says, for
> example, "Report from database1".
>
> In the report, assign the most used database to the query's databasename
> property.  This means you can simply run the report, without using the
> launch form, if you want data from that database.
>
> Create a launch form.
>
>     function form_onOpen
>       set procedure to myreport.rep
>       //create an instance of the form in memory.
>       form.rep = new myreportReport()
>       return
>
> Wit an instance of the report in memory you can change any property of
> any object in the report before you render the report.
>
>
> Add two pushbuttons to the launch form and set the text property of one
> to  'Database1 and the text property of the other to 'Database2'
>
>
>    function PUSHBUTTON1_onClick
>       form.rep.pagetemplate text1.text := "Report from database1"
>       form.rep.queryname.active = false
>       form.rep.queryname.databasename = 'dbase1objectname'
>       form.rep.queryname.active = true
>       form.rep.render()
>       return
>
>    function PUSHBUTTON2_onClick
>       form.rep.pagetemplate text1.text := "Report from database2"
>       form.rep.queryname.active = false
>       form.rep.queryname.databasename = 'dbase2objectname'
>       form.rep.queryname.active = true
>       form.rep.render()
>       return
>
> If you use the launch form you can print the report using either database.
>
> Mervyn.
>
>