ComponentOne True DataControl 8.0
Tutorial 15 - Query Mode (part 1)

In this tutorial you will try a powerful new feature of True DataControl: Query Mode.

Query Mode enables you to build ad-hoc query forms in a matter of minutes. True DataControl Query Mode is an enhanced version of the Microsoft Access “Filter By Form,” and implements the paradigm known as “Query By Example."

In this tutorial, we will create a form that can function in two modes: query and results. The same TData control and the same DataGrid are used to represent data in either mode.

Tutorial 16 will demonstrate another option that you have with True DataControl query mode: you will use a TData control and data-bound controls that are intended solely for entering queries, results will be displayed with a separate TData control in a separate DataGrid.

  1. Start a new project.

  2. Place the following controls on the form (Form1) as shown in the figure: a TData control (TData1), a DataGrid control (DataGrid1) and two buttons (Command1, Command2).

  3. Set properties as follows (you can use the DataSource property page to set TData data source properties, as described in Tutorial 2):

    Example Title
    Copy Code
    TData1.ConnectionString
    
    Provider=Microsoft.Jet.OLEDB.3.51;Persist Security
    
    Info=False;Data Source=C:\Program Files\ComponentOne Studio\Common\TDDEMO.MDB
    
    TData1.CommandType   2 – adCmdTable
    
    TData1.RecordSource  Products
    
    TData1.QueryMode     True
    
    DataGrid1.DataSource TData1
    
    DataGrid1.AllowAddNew      True
    
    DataGrid1.AllowDelete      True
    
    Command1.Caption     Query Mode
    
    Command2.Caption     Apply Query
    
  4. Open the True DataControl property pages for TData1. On the General page check the Query Mode check box in the Buttons group, which will make the Query button visible.

  5. On the Fields property page of TData1, select the ProductName field. Select starts with in the Query Operation combo box.

  6. Add the following code to Command1:

    Example Title
    Copy Code
    Private Sub Command1_Click()
    
    TData1.QueryMode = True
    
    End Sub
    
  7. Add the following code to Command2:

    Example Title
    Copy Code
    Private Sub Command2_Click()
    
    TData1.QueryMode = False
    
    End Sub
                                    
                                    
    

Run the Program and Observe the Following:

Close the program. You have successfully completed Tutorial 15.

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback