Editing Repository Objects

Regardless of the type of Repository Object, from time to time, objects will likely need to be updated. For example, the company address text object would need to be updated if the company moves to a new location. To successfully update any repository object, two fundamental steps must be taken:

  1. Disconnect the object from the repository and then make the change to the object.

  2. Update the object in the repository.

Disconnecting a Repository Object

Because the Repository is basically a library to store objects, it has no update functionality in itself. This means that updates to objects must be done directly inside a Crystal Report. All connected repository objects are automatically considered read-only and cannot be changed. To update a specific object, you first need to disconnect it from the repository. This can be done by right-clicking on the object and choosing Disconnect Repository Object in the Design or Preview tabs.

graphics/alarmclock_icon.gif

Remember that there are different places where repository objects can be accessed and acted upon depending on their type. Text objects and images can be accessed from the Repository Explorer and the design application's Design and Preview tabs. SQL Commands can be accessed from the Report Wizard and the Data Expert. Custom functions can be accessed from the Formula Workshop.


After the object is disconnected, the needed changes can be applied to the object. However, the changes do not become global to the repository and all other reports using the object until the object is connected back to the repository.

Reconnecting an Updated Object to the Repository

Now that the object has been updated as desired, only the report where the update has occurred is currently changed. This is because the repository has not been made aware of the change. To make the repository aware, the object must be reconnected to the repository.

To reconnect a text object or image to the repository, simply drag and drop the object from the Design/Preview environment back to its original repository object name/location in the Repository Explorer. A dialog will appear to confirm if you want to update the original object or add a new one. Because Update is already chosen, clicking OK will update the object.

For example, if a logo has been changed and the original object was called corporate logo, drag the new logo image directly over the name corporate logo in the Repository Explorer. When prompted to update or add, confirm it as an update and click OK. The corporate logo for this report will now be reconnected, and the repository will be updated for all other reports as well.

To reconnect a Custom Function in the Formula Editor, simply right-click on the disconnected and updated custom function's name in the workshop tree and choose Add to Repository. There will be a prompt for which specific repository you want to update. But because there is only one in this case, clicking OK will reconnect the object and update the repository in one step.

graphics/bookpencil_icon.gif

Because Custom Functions are called by name, no two custom functions in the repository can have the same name. Notice that no dialog requesting Add or Update has appeared. This is because the name of the Custom Function hasn't changed, and it will automatically update the existing one.

If the name for a custom function has been changed (perhaps because it's a hybrid of another function), it will be added to the repository under the new name.


To reconnect a SQL Command to the repository, the Add to Repository toggle in the Modify Command dialog (where the changes to the command have been made) will need to be selected. Once the OK button is clicked, the updated command will be reconnected to the repository. This can be done from either the Database Expert dialog or the Data tab in the Report Expert.

graphics/lightbulb_icon.gif

When updates occur to objects in the repository, the older versions are not actually gone. They are simply not viewable in the Repository Explorer. Crystal Reports always looks for the latest version of an object to display in the report design application.

During an update action, the repository database increases the version number for the newly updated object automatically so that when the next call to the repository object is made (either by adding it new to a report or during the update action upon opening a report), the latest version number will be used.


Sharing a Repository with Others

The focus of this lesson has been on sharing objects, formatting and logic between reports. This focus has been for one report designer to increase his productivity. However, the idea of a report object repository raises the question, "Can this sharing of information be shared between multiple report designers?"

The answer to this question is yes. By creating the repository as a database, the idea was two-fold to share knowledge between reports as well as to share that same knowledge with other report designers. However, the underlying database type is the key.

Crystal Reports needed to provide the sample Crystal Repository in a small compact database, so Microsoft Access was chosen as the default source. However, this database is not conducive to sharing among many users. Fortunately, the fact that an open data access method (ODBC) is used as a middle tier (or middleman) means that other relational databases could be used as well.

For example, if a report designer has access to Microsoft's SQL Server database, he could publish his repository to this database source (by importing his existing MDB) and give access to the repository to other colleagues. By sharing one repository, all the report designers would more likely be consistent across their reports and more productive with their design efforts.

To inform the Crystal Reports application about the change to the location of the data source, the report designer will have to create an ODBC data source for his new database.

graphics/alarmclock_icon.gif

Make sure that Crystal Reports is closed before making this change.


graphics/bookpencil_icon.gif

For more information on how to create an ODBC DSN specification, follow the directions located in the Crystal Reports Help files to ensure correct configuration of Data Source Names (DSN).


After the data source is created, edit the ORMap.INI located in c:\program files\common files\crystal decisions\2.0\bin. Change the name after the = sign at the end of the file to be the exact data source name that has recently been created. Run Crystal Reports and open the Repository Explorer. Notice that the database has changed to the new data source.

graphics/alarmclock_icon.gif

If the new database requires a username or password to connect to it, these credentials will be prompted for upon initially opening the repository. But, opening and closing the repository explorer will not log off the server. Therefore, prompting is kept to a minimum.


graphics/lightbulb_icon.gif

Because the repository is now shared with others, it can be updated and maintained by others as well. If there is a need to limit the updating ability, this must be done on the database side by limiting the update rights of a particular user.


graphics/bookpencil_icon.gif

For more information on rights, see your database documentation because all databases are different.




Sams Teach Yourself Crystal Reports 9 in 24 Hours
Sams Teach Yourself Crystal Reports 9 in 24 Hours
ISBN: B003D7JUVW
EAN: N/A
Year: 2005
Pages: 230

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net