home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Visual Basic 6 Black Book
(Publisher: The Coriolis Group)
Author(s): Steven Holzner
ISBN: 1576102831
Publication Date: 08/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


Updating A Database With Changes

After changing the fields in a record, you can update a database with the UpdateRecord method of the data, ADO data control, or remote data control. Let’s see an example. When the user clicks the Update button in the dbmethods example we’re developing in this and the previous few topics, we can update the database with the new record like this:

Private Sub cmdUpdate_Click()
  Data1.UpdateRecord
End Sub

Moving To The Next Record

You can move to the next record of a database with the MoveNext method of the Recordset property of a data or ADO data control, or of the Resultset property of a remote data control. Let’s see an example. When the user clicks the Next button in the dbmethods example we’re developing in this and the previous few topics, we can move to the next record like this:

Private Sub cmdNext_Click()
  Data1.Recordset.MoveNext
End Sub


TIP:  You can use the RecordCount property of a Recordset or Resultset to determine how many records you have to work with, and so make sure you don’t go past the end of the database.

Moving To The Previous Record

You can move to the previous record of a database with the MovePrevious method of the Recordset property of a data or ADO data control, or of the Resultset property of a remote data control. Let’s see an example. When the user clicks the Previous button in the dbmethods example we’re developing in this and the previous few topics, we can move to the previous record like this:

Private Sub cmdPrevious_Click()
  Data1.Recordset.MovePrevious
End Sub


TIP:  When you use MovePrevious, make sure you don’t try to move back before the first record of the database.

Moving To The First Record

You can move to the first record of a database with the MoveFirst method of the Recordset property of a data or ADO data control, or of the Resultset property of a remote data control. Let’s see an example. When the user clicks the First button in the dbmethods example we’re developing in this and the previous few topics, we can move to the first record like this:

Private Sub cmdFirst_Click()
  Data1.Recordset.MoveFirst
End Sub

Moving To The Last Record

You can move to the last record of a database with the MoveLast method of the Recordset property of a data or ADO data control, or of the Resultset property of a remote data control. Let’s see an example. When the user clicks the Last button in the dbmethods example we’re developing in this and the previous few topics, we can move to the last record like this:

Private Sub cmdLast_Click()
  Data1.Recordset.MoveLast
End Sub

The Data-Bound Controls: From Text Boxes To Flex Grids

After installing a data, remote data, or ADO data control, you can connect that control to other controls through a process called data binding. You bind controls to a data control using the data properties of the bound control. The standard bound controls and their data properties appear in Table 24.1. Using the information in that table, you can connect the listed Visual Basic controls to data controls, remote data controls, and ADO data controls.

Table 24.1 The bound controls.
Control Properties To Set
Checkbox DataField = Desired Boolean field; DataSource = Data control’s name
Combo box DataField = Desired field; DataSource = Data control’s name
DBCombo box BoundColumn = Desired field; DataField = Desired field; DataSource = Data control’s name; ListField = Desired field to display in the combo’s list; RowSource = Data control’s name
DBList box DataField = Desired field; DataSource = Data control’s name; RowSource = Data control’s name
FlexGrid DataSource = Data control’s name
Image control DataField = Desired field; DataSource = Data control’s name
Label DataField = Desired field; DataSource = Data control’s name
List box DataField = Desired field; DataSource = Data control’s name
MaskedEdit DataField = Desired field; DataSource = Data control’s name
MSFlexFrid DataSource = Data control’s name
Picture box DataField = Desired field; DataSource = Data control’s name
Text box DataField = Desired field; DataSource = Data control’s name
Rich text box DataField = Desired field; DataSource = Data control’s name


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.