Frequently, in addition to a simple data output, it may be necessary to perform different kinds of data manipulation, such as summation, calculation of simple average, etc.
Let's discuss a few concrete cases by the example of "Cars" table in test MS Access database (examples.mdb) that comes with ASPRunnerPro. Depending on complexity of solving problem you need to make some changes on Events tab, on Edit SQL query tab or on the Visual Editor tab.
1. Open your project and proceed to Edit SQL Query tab.
2. Switch to the SQL mode.
3. In SQL mode add string ([EPACity] + [EPAHighway])/2 as AvgEpa.
4. Proceed to Choose fields screen.
5. For AvgEpa field unselect following checklists: Add, Edit, Inline Add, Inline Edit.
6. Build your project and view results in browser.
For next two items you should modify your database for a bit. Add to Cars table numeric field Tax. It's important, that this field should be able to hold fractional values (use float or double datatype).
1. Click on Before Record Updated Event.
2. Modify sample event code by putting following code snippets to appropriate place.
3. Apply the same code to Before Record Added Event.
1. Open your project and proceed to the Events tab.
3. Add following code:
Now you can edit or add new records and every time when you make changes in Horsepower or Price field correspondingly Tax field has changed. It's very comfortable 'cause right away you see imposed tax and can modify price depending on it.