Share this Page URL

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

Using Visual Basic to Manage Data 589 Notice the criteria entered for the StartDate, Priority, and Country fields. (For Priority, the value 1 is the PriorityID for High.) These values come from controls on the TasksReport form and are included in the WHERE clause of the SQL statement that serves as the report's record source. For more information about the elements of a SQL statement, see Chapter 9, "Ex- tending Your Use of Queries." Close the Query Builder window and the report. You can click No when you're asked to save the report's design. On the toolbar, click the View button to switch the TasksReport form to Design view. Right-click the View Tasks button, and then click Build Event. You'll see the code for the but- ton's Click event procedure in the Visual Basic Editor, as shown here: See Also 7. 8. 9. Here's the code for the event procedure, for ease of reference: Private Dim Dim Dim Dim Dim Sub cmdViewTasks_Click() intPriority As Integer strSelect As String strCountry As String strStartDate As String strWhere As String intPriority = Me.fraPriority.Value Select Case intPriority Case Is = 1 strSelect = "SELECT TaskName, StartDate, Priority, DueDate, " & _ "Status FROM qryTasks" strCountry = lstCountry.Value strStartDate = txtStartDate.Value strWhere = "WHERE Country = " & "'" & strCountry & "'" & _ " AND StartDate > " & "#" & strStartDate & "#" & " AND Priority = 1;"