Crystal Reports 10: The Complete Reference
Adding To/Updating the Repository
Once you ve installed your initial Crystal Enterprise 10 system with its default database, you ll need to begin to populate it with your shared objects. And while it s not required, you ll probably gain more usability with the repository if you organize the repository into folders.
Note | The ability to add, change, and delete repository objects and folders is based on Crystal Enterprise security. If your CE user ID hasn t been granted these rights, you ll receive errors when you attempt these operations. Steps to control these rights are discussed later in this chapter, under Controlling Repository Rights. |
Creating Folders
You may create as many folders in the repository as you like. And you re not limited to creating a single level of folders ”you may create subfolders within other folders to build a hierarchy for repository objects. Once you ve created your folder structure, you can place text objects, bitmap graphics, or SQL commands in the folders (custom functions are placed in a separate part of the repository reserved just for themselves ”they won t appear in the Repository Explorer).
From within Crystal Reports , you create, delete, or modify folders from the Repository Explorer. Launch the Repository Explorer by clicking the Repository Explorer button in the Standard toolbar, or choose View Repository Explorer from the pull-down menus . If you have not already logged on to Crystal Enterprise, you ll be prompted to do so. If you have not yet modified the repository, you ll see the name of your server at the top of the explorer, followed by the folders initially supplied by the out-of-the-box CE repository.
You may create a top-level folder that appears directly underneath your CE server name, or a subfolder that exists within another folder. If you wish to create a top-level folder, ensure that you ve selected the CE server name first. Click the folder button in the Repository Explorer toolbar, or right-click the CE server and choose New Folder from the pop-up menu. A folder will be added to the repository with the default name of New Folder, and you ll be placed immediately into edit mode, where you can type your own name for the folder. Type the new folder name and press ENTER or click elsewhere with your mouse.
If you wish to create additional folders, you may create top-level folders by repeating the previous steps (just make sure you ve selected the CE server prior to clicking the folder toolbar button). If you wish to create a subfolder below an existing folder, select the higher-level folder first. Then, click the folder button in the Repository Explorer toolbar or right-click and choose New Folder from the pop-up menu. You ll see a lower-level folder within the higher-level folder you right-clicked, again with the default name of New Folder, which you can rename immediately.
If you wish to rename a folder you ve already added, select the folder you wish to rename and then hold the mouse button down on the folder for a few seconds. You may also select the folder and press F2, or right-click the desired folder and choose Rename from the pop-up menu. In all cases, the folder name will go into edit mode and you can type a new name for the folder.
Deleting folders is similarly straightforward. Select the folder you wish to delete and simply press the DEL key. Or, you may click the X button in the Repository Explorer toolbar or right-click the desired folder and choose Delete from the pop-up menu. You ll be prompted to confirm the deletion. If there are any objects in the folder, they will be deleted along with the folder.
Caution | Deleting folders, like deleting individual objects in the repository, cannot be undone. Make sure the object or folder you want to delete is no longer needed before you delete it. |
Adding and Deleting Objects
You may add report objects to the repository at any time, even if you haven t yet created any folder structure (moving objects into or among folders will be discussed later in the chapter). The method for adding an object to the repository is dependent on the type of object you wish to add.
Text Objects or Bitmap Graphics
A text object or bitmap graphic can be added to the repository by simply dragging and dropping it from the Design or Preview tab of the report into the Repository Explorer. If you wish to place the object into a particular folder, drag and drop the text object or bitmap on top of the folder you wish to add it to. You may also add a text object or bitmap by right-clicking the desired object and choosing Add to Repository from the pop-up menu.
Specify a name for the object to appear in the repository. Make sure you don t use a name already used for another repository object of the same type in the same folder (you ll be warned if you do this and will overwrite the repository object with the same name if you proceed). You can, however, add a repository object with the same name into a different folder.
Although not required, you can also add an author name and description for your entry. If you choose the pop-up menu method to add the object, the Repository Explorer will appear within the Add Item dialog box. If you wish to place the object in a folder, choose the folder where you want to place the new object. If you select the name of CE server instead of a folder, the object will be placed directly under the server name in the Repository Explorer. Click OK when you ve specified all information to add the object to the repository.
If you wish to rename an object you added to the repository previously, you may simply select the object inside the Repository Explorer and then hold the mouse button down for a few seconds. The object will go into edit mode, where you can type in a new name (you ll receive an error if you try to use a name of another object of the same type and name in the same folder), and press ENTER or click away from the object name. The object will be renamed .
If you initially place an object in a particular folder (or in no folder, but right below the server name itself), you may move or copy it to another location with a simple drag-and-drop operation. Select the object you wish to move and hold your mouse button down. Then, drag the object on top of its new preferred location (a folder if you wish to move the object to that folder, or the server name if you wish to move the object out of a folder and place it right below the CE server). When you drop the object in its new location, it will then appear where you dropped it. Holding the CTRL key down while dragging will copy the object to its new location, also leaving the object in its original location. If there is already an object with the same name in the destination folder, you will be warned that it will be overwritten.
Deleting a text object or bitmap from the repository is similar to deleting folders. Just select the object you want to delete and press the DEL key. You may alternatively click the X button in the Repository Explorer toolbar or right-click the object and choose Delete from the pop-up menu. And as with folders, deleting text objects or bitmaps can t be undone. Make sure you really want to delete the object from the repository before proceeding. Note that deleting an object from the repository won t delete it from reports that had originally made use of it. It will still remain in those reports, but it won t be available to add to any new reports.
While you can t add a SQL command to the report from the Repository Explorer (you must do this in the Database Expert), you can rename or delete it from there. Use the same steps mentioned previously for deleting or renaming text objects and bitmaps to delete or rename SQL commands.
Note | If you delete an object from the repository that may be part of existing reports, users will receive an error message when they open the report and attempt to Update Repository Objects. The object on the report will then appear as it did when the report was last saved. |
Custom Functions
Add custom functions to the repository from the Formula Workshop. With the Formula Workshop displayed, select the report custom function you wish to add to the repository and click the Add to Repository button. You may also right-click the custom function name and choose Add to Repository from the pop-up menu. And you may also simply drag the custom function name from the Report Custom Functions category of the Formula Workshop to the Repository Custom Functions category (drop on top of any item in the category).
Note | You won t be prompted for a folder to place the custom function in. The folder structure discussed earlier applies only to text objects and bitmaps. Custom functions are placed in a separate area of the repository just for them. If you assigned categories to your custom functions when you created them, the categories will be retained when you place the custom function in the repository. |
Deleting a custom function from the repository is quite straightforward. Simply expand the Repository Custom Functions category of the Formula Workshop, select the custom function that you wish to delete, and press the DEL key. You may alternatively right-click the custom function name and choose Delete from the pop-up menu. In either case, you ll be warned that deleting a custom function from the repository can t be undone. Confirm that you want to delete the function and it will be permanently removed from the repository. Note that deleting an object from the repository won t delete it from reports that had originally made use of it. It will still remain in those reports, but it won t be available to add to any new reports.
Tip | The sample repository shipped with Crystal Enterprise 10 contains a few sample text objects, SQL commands, and bitmaps. These are for demonstration only and will be of little or no use to you when designing your own reports. There are, however, some useful custom functions supplied with the CE repository that you may find of use in your own reporting tasks . |
SQL Commands
Add SQL commands to the repository in the Database Expert (creating SQL commands is discussed in more detail in Chapter 16). First, create the SQL command so that it appears in the Selected Tables list of the Database Expert. Then, right-click and choose Add to Repository from the pop-up menu.
If you haven t previously logged on to CE, you ll be prompted to do so. You ll be presented with a dialog box similar to previously described dialogs prompting you to name the object and choose a location in the repository for the object (SQL commands can be stored in the same folder structure you set up in the Repository Explorer). You may optionally specify the author, as well as changing the description for the SQL command to something other than the SQL statement that makes up the command (which is placed in the description text box by default). When you click OK, the SQL command will be added to the repository. It will then appear in the Repository section of the Database Expert.
Note | You ll also be able to see SQL commands in the Repository Explorer alongside text objects and bitmaps ”they ll just be displayed with a different icon. However, you won t be able to just drag and drop them to the report as you can text objects or bitmaps. You can, however, rename and delete SQL commands from the Repository Explorer using the same techniques described for text objects and bitmaps. |
You may rename a SQL command you added to the repository either in the Repository Explorer or the Crystal Enterprise Explorer that appears when you first log on to the repository from the Database Expert. The process is identical in all situations. Select the object, hold down the mouse button for a few seconds to put the object in edit mode, and make the change. You may also right-click and choose Rename from the pop-up menu.
Deleting a SQL command from the repository must be done in the Repository Explorer ” you cannot delete a SQL command from the repository in the Database Expert. Once you ve closed the Database Expert and have arrived at the report Design tab, display the Repository Explorer. Navigate the folder structure to find the desired SQL command. Right-click the SQL command name and choose Delete from the pop-up menu, click the X button in the Repository Explorer toolbar, or press the DEL key. Note that deleting an object from the repository won t delete it from reports that had originally made use of it. It will still remain in those reports, but it won t be available to add to any new reports.
Note | New Crystal Reports 10 Business Views are also stored and managed in the repository. Complete details on how to maintain repository-based Business Views are available in Chapter 17, Creating and Using Business Views. |