PreviousTutorials and Guide to Samples (9.1 revision 1) Next

Lesson 1: ActiveX Tutorials with Visual Basic

Show this topic in Library frames

Preparing the ActiveX Interface

  1. Add the Pervasive ActiveX Data Source and the Pervasive Bound Controls to your Visual Basic toolbar.


Using the VAccess control in Visual Basic

  1. Select a VAccess data control and place it on a form.

  2. Set the Btrieve File properties of the control.
    1. Right-click the control and choose Properties. Or, select View > Property Pages.
    2. Set the Btrieve file properties on the File Information tab as follows:
    3. DdfPath - The location (drive and path) of the DDFs containing the definition for the data file attached to the control.
    4. TableName - The table name (in the DDF specified in the DdfPath property) of the data file to attach to the VAccess control.
    5. Location - The operating system file name of the data file attached to the control. Defaults to the table location of the table specified in the TableName property. This property should either contain a fully-qualified path and file name for the data file, or a file name only. If you do not explicitly specify a path, the control will attempt to open the data file in the location specified in the DdfPath property.


  3. Click the Settings tab, and verify the IndexNumber value.
  4. In the combo box, choose the desired index on the Btrieve file.


  5. Choose whether to use Extended Operations.
  6. Extended operations allows your application to retrieve a number of records at a time from a Btrieve server, and performs limited server-side filtering based on values of fields. Extended operations can dramatically increase the performance of some record retrieval operations.

    Click the Extended Operations Properties tab. To activate Extended Operations, check the ExtendedOps check box. To turn off Extended Operations, clear the ExtendedOps check box.



  7. Click OK.
  8. Add the following code to the Form_Load Event, substituting the name of your control for VAccess1:
  9. VAccess1.GetFirst 
    

Add code for an initial query, if desired.

Using a VAText control

  1. Add the control to a form. See page 5-3, "Select a VAccess data control and place it on a form."
  2. Set the VAccess property of a bound control. See page 5-7, "Set the VAccess property of a bound control."
    1. Open the Properties dialog box of the bound control.
    2. Click on the VAccessName combo box down arrow.
    3. Select the desired control from the drop-down list.
  3. Set the VAFieldName property.
    1. Click the VAFieldName combo box down arrow.
    2. Select the desired field from the drop-down list.


  4. Set the VASearch property.
  5. Setting this property to True causes the VAccess control to perform a GetGreaterOrEqual method using the value in the text box for the first segment of the index specified by the IndexNumber property of the data source each time the text changes. The setting of the VAFieldName property is ignored.

    1. To set the property to True, select the VASearch check box.
    2. To set the property to False, clear the VASearch check box.
  6. Click OK.

Using a VAList Control

  1. Add the control to a form.

  2. Set the VAccess property of a bound control.
    1. Open the Properties dialog box of the VAList control.
    2. Click on the VAccessName combo box down arrow.
    3. Select the desired data source control from the drop-down list.


  3. Set the VAAutoScroll property.
  4. Setting this property False prevents the currently selected list box item from automatically scrolling to the top of the list if the list is used as an auto-fill record list (VARecordList = True)

    The default behavior of the record list VAList (VARecordList = True) is to keep the current record as the first item in the list box, whether or not the positioning was changed by the list box or by other means, such as a scroll bar or a GetEqual command.

    If VAAutoScroll is False, this default behavior is defeated and the VAList moves the current record to the top of the list only when positioning is changed by a source other than the list box itself. For example, clicking on an item in the list box will reposition the VAccess control, but will not change the items in the list box.

  5. Set the VARecordList property.
  6. Setting this property True changes the mode of the list box or combo box control from a field-bound control to a record browser.

    The VARecordList property causes the list control to be filled with as many records as it can hold. The top item of the list is the current record (unless the VAAutoScroll property is set to False, in which case the selected list item represents the current record).

    When VARecordList = True, several added features are available and may be accessed at design time via buttons on the property page. The VAFieldName and VAFormat properties, which are limited to one entry when the control is in field-bound mode (when the VARecordList property is False), can contain a list of fields and formats, respectively, separated by semicolons. In addition, the VAAutoScroll and ColumnWidth properties become active.

  7. Select the fields to display.
  8. To select a single field to display in the VAList:

    1. Left-click the down arrow of the VAFieldName combo box
    2. Select the desired field from the drop-down list.
    3. To display multiple fields in the VAList:

    4. Left-click the text field of the VAFieldName combo box.
    5. Type in the fields you wish to display, separated by semicolons (`;').
    6. Or:

    7. Left-click the ellipsis button ([...]) next to the VAFieldName text box.
    8. Double-click each field you want to add.
    9. Click OK.
  9. Set Column Widths.
    1. Click on the ellipsis (...) button next to the ColumnWidth Edit box.
    2. In the Edit Box, double click at the desired right edge of the first column of the VAListBox. Repeat for each column except the last. You may drag the column lines to new positions after this is done.

Joining two VAccess controls

The Join property of the VAccess control allows you to specify that two files be linked by a key value, such that any changes in the record positioning of the first (master) file will also affect the records retrieved from the second (slave) file. The Join property provides a simple mechanism for browsing a relational database.

The joined fields in the slave control must be index fields and must contain the same raw data as their corresponding fields in the master control. The fields in the master control do not have to be indexes. The IndexNumber property of the slave control must remain set to the index involved in the join or the join will be broken.

One-to-one, many-to-one, and one-to-many joins are all supported. Note that a one-to-many relationship is most effective if the ExtendedOps property of the slave VAccess control is set to True. In this case, the slave control automatically retrieves all records which match the key value in the master control, and makes the field data available through its RowColumnValue property. The data can be displayed in a VAListBox in record list mode by setting its VAccessName property to the name of the slave control and its VAFieldName property to the fields to be displayed. Set the Join property of the slave control by completing the following steps.

  1. Open the slave control's Properties dialog box.
  2. Click the Settings tab.
  3. Set the appropriate index.
  4. Click the File Information tab.
  5. Click the Join button on the File Information tab.
  6. Left-click the down arrow of the To VAccess combo box.
  7. Select the Master file from the drop-down list.
  8. In the Where list box, select the slave file index to link to the master file.
  9. In the Fields list box, double-click on the Master file field to which you want to link the slave file.
  10. Click OK to close the Join dialog.
  11. Click OK to close the VAccess property pages.

Using a VACommand control to perform Btrieve operations

  1. Add the control to a form. See page 5-3, "Select a VAccess data control and place it on a form."
  2. Set the VAccess property. See page 5-7, "Set the VAccess property of a bound control."
  3. Set the VAOperation property.
    1. Click the Operation Settings tab of the Properties dialog box.
    2. Click the VAOperation combo box down arrow.
    3. Select the desired Operation from the drop-down list.



Chapter contents
Publication contents

Prev topic: Advanced Pervasive.SQL Tutorials Using Visual Basic
Next topic: Lesson 2: Btrieve API Tutorials with Visual Basic