Using Formula in Crystal Report. The formula field in a Crystal report is a functionality provided to enhance computation of values dynamically during the display/printing of records in a report of an application. Abstract. The ultimate goal of most commercial software is the generation of useful and accurate reports for the requirements of the users in enhancing the decision making process at the managerial level of the enterprise. Exporting Crystal Report Using VB6. Priya asked Feb 19, 2013. Now I am able to convert crystal report to PDF. The FreeVBCode site provides free Visual Basic code, examples. How to add crystal report xi in vb6 by code. Abhishek Singh asked Sep 15, 2010. But I want to call all the reports in one form and one CRViewer using code. How to Load and Display Crystal Reports. The sample code for calling. There are several types of data sources that you can use in Crystal Reports. They are the tables that are used in the sample. This is the snippet Billing And Report Generation (Crystal Reports. And Report Generation (Crystal Reports. Notwithstanding the existence of some other forms of reporting tools, Crystal Report has found enormous patronage in the development of concise and reliable reports. In this paper, the use of one of its functionalities – formula – is used to demonstrate the implementation of the electronic bin card (e- Bin. Card). The bin card is used to manually track individual items in stock of most merchandising company and stores/warehouses in most of the developing nations of the world, including Nigeria. However, this is gradually being replaced by software applications capable of performing the same function. For this demonstration, a stock management application is presented with the implementation of an e- Bin. Card using the formula field of the Crystal report design tools to compute dynamically the stock balance. ![]() Using crystal report in vb6. A Sample To Print A Report Using Crystal ReportLooking For A Sample. How can i connect and use Crystal reports using source code only. Just like in Visual Basic 6.0, to use the Data Report (*.dsr), the code will follow just like this. ![]() Introduction. The formula field in a Crystal report is a functionality provided to enhance computation of values dynamically during the display/printing of records in a report of an application. Most developers often fail to effectively explore the potentials of this Crystal Report functionality and often preferred other report viewing modules. ![]() Formulas in Crystal report have two forms of syntax; Basic and Crystal. In this paper, a few of the details on the syntax, data types, return values and case sensitivity will be demonstrated. Formulas are always used to return a value or Insert a value where desired. The data types returned must be simple and can be Number, Currency, String, Boolean, Date, Time and Date. Time. You cannot return complex data types such as range or array. Formulas return a value by assigning the value to the Formula variable and must always return a value. These values are automatically assigned to the field the formulas are inserted. The Stock Bin Card will be used to demonstrate the use of formulas and this will enhance the reader’s knowledge of formula in Crystal report. The Stock Bin Card. The Bin Card is a manual technique of maintaining stock movement in a warehouse. The Bin Card contains the following elements/fields; Stock Code, and Description, date of operation, Opening balance, Quantity received and dispatched/sold stock balance and staff Identity. Although getting this type of report from the Crystal Report module may look easy but the Group By or Order By functionality may be muddled up when computing the Stock Balance rendering the report meaningless. It is expected the reader has minimal knowledge of Visual Basic. NET and My. Sql for ease of understanding as will be demonstrated in the course of this paper. The example is broken down into three parts; the table (My. Sql), form (design – VB. What is the sample code for crystal report viewer. What is the sample code for crystal report viewer 8.5 in VB6.NET and Crystal Report) and the program (VB. NET). The Database, Table and Columns. Databases are created in My. Sql using the instruction “Create database nameofdatabase” while tables are also created with the instruction “Create table tablename”. The bincard database and the stockbincard table are thus created. The creation and use of Database and Table are illustrated in My. SQL Tutorial. Alternatively, the My. SQLAdmin could also be used for the same purpose as illustrated in figure 2. The My. SQL query browser could be used to confirm the creation of the database and the table respectively along with the columns. The Stock. Bin. Card Project. The Stockbincard project is created in the VB. NET environment and the following forms are created: The stkbinmenu. The main menu form for the project (figure 3). The form contains three submenus to access the three basic functionalities of the e- Bin. Card. The dataentry. This form provides the mechanism for data entry into the database. The receipts and dispatches are registered for the stock item. If the stock item is a new product, it passes into creation mode, else it accepts the data in either of the operations (receipts or dispatches) (see figure 4). The following code fragments suffixes. Public. Function Get. Details(By. Val str. Code As. String) As. Int. 16. Sql = . It is important to state here that the Stock. Code column of the database is not used as a key, therefore multiple occurrence of records is allowed. The stk. Module. vb contains the declaration of common variables (global) used in the project. The Report. Bin. Card. View. vb – implements the viewing of the report generated by the crystalreport viewer (see figure 5): This is the form that . The following code segment is associated with the viewer to load the output of the select statement (see figure 7) to the View. Report. Bin. Card. Private. Sub View. Report. Bin. Card. The following code segment generates the dataset . The following codes will be used to achieve the desired result in the following order (see figure 7): The select statement The connection to the database An instance of Odbc. Command – Xycommand. An instance of Odbc. Data. Adapter – Kadapter. Filling the dataset – Rdata. Loading the report – myreport – and setting the Report Report. Source. Display the report - View. Report. Bin. Card. The Formula Field. As earlier indicated, the stock balance will be computed and displayed dynamically using the Crystal Report Formula. When creating formulas, you have the option of using either Crystal or Basic syntax. Almost any formula written with one syntax can be written with the other. Reports can contain formulas that use Basic syntax as well as formulas that use Crystal syntax, but a single formula can use only one syntax. In the computation of the stock balance, we shall demonstrate with both the crystal and basic syntax options. The Basic Syntax. The Microsoft MSDN Library clearly explains the Basic syntax of the crystal report and employs the same syntax as the BASIC language. An exception is that a value must be returned in the special variable Formula. It is not case- sensitive and contains data types such as string, integer, etc. In figure 8 below, the option Basic Syntax is selected, the table columns highlighted, and the formula also encircled. The formula for the computation of the stock balance is given at the code section of the formula workshop: Global Bal. Qty As Number - declares the global variable Balqty as an Integerif . The Crystal Syntax. The crystal syntax is equally illustrated and explained in the MSDN Library. The syntax is quite different from the Basic Syntax. The value returned by a crystal syntax does not have to be attached to a variable but the variable value itself. Any of the data types could be returned as a value. This will be displayed at the position in the report containing the formula. This is demonstrated below in figure 9. How the Program Works. Once the program is launched, upon a successful connection to the database – bincard - , message of successful completion is displayed otherwise an error message (See figure 1. Thereafter, the Main Menu is displayed with the following options: Receive Stock – To register receipts. Dispatch Stock – To register dispatches Print Bin Card – To print Bin Card. During the registration of stock (receipts or dispatches), if the item is new, the program creates the item otherwise, the information on the stock is displayed, i. A sample report output is shown in figure 1. Conclusion. The stockbincard has been used to demonstrate the use of an electronic stock bin card. In its present form, it looks simple but is a good demonstration of the use of Formula fields in crystal report. Other functionalities such as; periodic choice of printing the electronic Stock Bin Card, inclusion of the staff Identity, etc. It is hoped the reader would find this example useful and be able to enhance it for other requirements. The source program could be downloaded here. Suggested Further Reading. My. SQL 5. 1 Reference Manualhttp: //dev. My. SQL Tutorialhttp: //www. Tutorial/MSDN for Visual Studio 2. Visual Basic . NET Programming for Beginnershttp: //www. Visual Basic and My. SQL developer Noteshttp: //www. ABC Company Ltd. 4. Asokoro, Abuja, Nigeria. Stock Bin Card Stock Code: 2. Description: Michelin Tyre Tubes 2. Date(dd/mm/yy)Receipts. Dispatch/Sold. Stock Balance. Staff Id./Sign. Comments. Tony. Opening Bal 1. Tony- 2. 2/0. 5/2. Andrew- 2. 3/0. 5/2. Tony- 2. 4/0. 5/2. John. Transfer. 27/0. Andrew. Damaged. 27/0. Tony- Figure 1: A typical Manual Stock Bin Card. Figure 2: The Stockbincard Table. Figure 3: The Main Menu for the Stock. Nin. Card Project. Figure 4: The Data Entry Form. Figure 5: The Report Viewer Form. Figure 6: The Crystal Report file Sql = . The Code for generating the report. Fig. 8: The Formula using Basic Syntax. Fig. 9: The Formula using Crystal Syntax. Fig. 1. 0: The Successful Connection Message. Figure 1. 1: A Typical report display Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
September 2016
Categories |