Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Change DataBase folder at runtime
Message
From
03/09/2001 05:48:41
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00550433
Message ID:
00551738
Views:
36
>>>>>How can i change the folder where my report can take data at runtime.
>>>>>I have used the ocx control and the "CrystalRuntime.Application" object but i don't find the method or property to set this value.
>>>>
>>>>Hope you're not using ODBC and this helps :
>>>>
Select * from myTable where Something into cursor myCursor
>>>>_CRReport("myCursor","c:\myCR_RPT_Files\", "myTest.RPT", "myTable")
>>>>
>>>>Function _CRReport
>>>>  Lparameters tcCursorName, tcPath, tcRPTName, tcTableName
>>>>
>>>>  lcAlias = alias()
>>>>  Select (tcCursorName)
>>>>  lcTemp = sys(2015)
>>>>  Copy to (tcPath+lcTemp) type fox2x
>>>>  oCrystal=CreateObject("Crystal.CRPE.Application")
>>>>  #Define WS_MAXIMIZE  29949952
>>>>  Declare integer GetForegroundWindow in WIN32API
>>>>  Declare short IsWindow in WIN32API integer
>>>>
>>>>
>>>>  oRpt = oCrystal.OpenReport(tcRPTName)
>>>>  With oRpt
>>>>    With .Database.Tables(tcTableName)
>>>>      .Location = tcPath+lcTemp+".dbf"
>>>>    Endwith
>>>>    With .PrintWindowOptions
>>>>      .CanDrillDown = .t.
>>>>      .HasCancelButton = .t.
>>>>      .HasCloseButton = .t.
>>>>      .HasExportButton = .t.
>>>>      .HasGroupTree = .t.
>>>>      .HasNavigationControls = .t.
>>>>      .HasPrintButton = .t.
>>>>      .HasPrintSetupButton =.t.
>>>>      .HasProgressControls  =.t.
>>>>      .HasRefreshButton  =.f.
>>>>      .HasSearchButton  =.t.
>>>>      .HasZoomControl  =.t.
>>>>    Endwith
>>>>    .preview ("Report Preview ",,,,,WS_MAXIMIZE,0)
>>>>  Endwith
>>>>  lnHwndActiveX = GetForegroundWindow()	&& Save window handle
>>>>  Do while IsWindow(lnHwndActiveX) # 0  && Wait while Activex Alive
>>>>  Enddo
>>>>  Clear dlls
>>>>
>>>>  Erase (tcPath+lcTemp+".*")
>>>>  If !empty(lcAlias) and used(lcAlias)
>>>>    Select (lcAlias)
>>>>  Endif
>>>>
Cetin
>>>
>>>In my app I use not free tables but database container so i have to use ODBC in my report. I use CR 7.0; i don't know if in CR 8.x VFP Database can be open directly without use ODBC
>>
>>Michele,
>>No you don't have to use ODBC. ODBC is slower. If you look into code closely it creates a fox2x version of the table requested. Requested table or (SQL) is in fact part of a DBC. Here a problem is that base table might have long fieldnames that are truncated when fox2xed. If you create the .rpt based on a fox2xed copy than it works faster than ODBC approach.
>>Cetin
>
>Yes, but if I have complex report with Parent and child table and i have to open more tables that belongs to database i have to set very complex query to obtain a table that contains all data i have to print. Is it so ?

Michele,
-You could create a series of SQL to get a final cursor you need, copy to fox2x type, create your .rpt based on it. Then same SQL snippet would work with the above.
-Or you could get fox2x versions of multiple tables, set relations and base your .rpt on it. With some modification to code you get the fox2x copies when you need the report, set the relations (same code snippet you wrote before creating the rpt) and call crystal.
With oRpt
   With .Database.Tables(tcTableName)
      .Location = tcPath+lcTemp+".dbf"
   Endwith
Lines then should set location for each tcTableName in report. IOW if in crystal you create a report based on a table 'c:\mypath\mydata\mytable.dbf' you could use the same report with a copy of table in :
'c:\mytemp\mytable.dbf'. This is where location points. After creating an .rpt you could just loop Database.Tables collection to check what the table names are and their location.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform