Share this Page URL

Chapter 17. Using Visual Basic to Manage... > Creating a Custom Report Feature - Pg. 587

Using Visual Basic to Manage Data 587 In this section, we'll describe how you can use values selected on a form to build an SQL statement that varies depending on the value selected. The SQL statement is then used as the record source for a report. In the example, we have a basic report that includes controls for the fields we want to see. We manage the data that's displayed in the report by building an SQL statement with a series of String variables in Visual Basic. The values held by the variables come from a form that's dis- played to a user. A feature such as this is another way in which a single report can be tailored to provide multiple views of your data. Create a custom report feature 1. Open the file HelloWorld17.mdb, located in the Chap17 folder where you copied the sample files for this book. As we have in other chapters, we've created some of the forms, queries, and other database objects that we'll use in this chapter's examples. All the database objects we've created use the techniques we've illustrated in previous chapters. If you have questions about how we put together any of these objects, open the object in Design view, and examine the property set- tings for the object and its controls. In the Database window, click Forms in the Objects list, select the form named TasksReport, and then click Open. The TasksReport form is shown here: 2.