As done for tables and queries, part of your job as a database developer consists of maintaining your reports. This include renaming, copying, or deleting the reports. Microsoft Access supports all of the necessary operations. As mentioned for a report, make sure that you need to perform the maintenance operation. If you perform an operation by mistake but have completed it, you cannot reverse it at will. You may have to recreate the object.
You can rename a report if you judge this necessary. As mentioned for a table or query, you cannot rename a report if it is opened: you would receive an error. To rename a report in the Navigation Pane, first click the Reports button that leads to its section. Once in the appropriate section, you can right-click the report and click Rename. This would put the name in edit mode, allowing you to type the new name and press Enter. To programmatically rename a report, you can call the Rename() method of the DoCmd object. The syntax to use is: DoCmd.Rename(NewName, acReport, OldName) The first argument is the name that the new or other report will have. The second argument must be acReport. The third argument is the name of the existing report that you want to rename. The object must exist in the Navigation Pane's section as specified by the second argument.
Instead of renaming a report, you can copy it and keep the original. To copy an existing report using the Microsoft Windows Save As routine, in the Reports section of the Navigation Pane, you can right-click the report and click Save As... This would open the Save As dialog box that allows you to enter the desired name of the copied report. Alternatively, you can right-click the report, click Copy, then right-click an empty area of the same section of the Navigation Pane and click Paste. This would open the Paste Report As dialog box in which you can enter the new name of the copied object. To programmatically copy a report, you can call the CopyObject() method of the DoCmd object using the following syntax: DoCmd.CopyObject [destinationdatabase] [, newname], acReport, sourceobjectname] The destinationdatabase argument is the name or path of the database where the copied report would be sent to. If you are copying the report in the same database, you can omit this argument. The newname argument is the name that you want the new report to hold. The third argument must be acReport. The last argument is the name of the existing report.
If you find out that you don't need a particular report anymore, you can delete it from the database. As mentioned already, when in doubt, don't delete it. To visually delete an object, in the Reports section of the Navigation Pane, right-click the report and click Delete. You would receive a warning before the report is actually deleted. To programmatically delete a report, you can call the DeleteObject() method of the DoCmd object using the following syntax: DoCmd.DeleteObject acReport, [objectname] The first argument must be acReport. When this method is called, if the report is already selected in the Navigation Pane, you can omit the second argument and the selected report would be deleted. Otherwise, to specify the report you want to delete, pass its name as the second argument of the method. |
|
|||||||||||
|