VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

Systems Analysis - System analysis and Design tutorial for Software Engineering

You are here: Visual Basic > Advanced VB6 tutorial > Chapter 8

Programmatically Writing VB Controls to a Record

When the user makes changes to controls and you want to save to the underlying data, you must programmatically write the contents of a control back to the underlying data in two steps:

  1. Write the contents of each control to its corresponding field in the copy buffer.

  2. Save the contents of the copy buffer to the underlying data of the Recordset.

To update a field in the copy buffer with a control's contents, you might code the following:

RecordsetName![FieldName] = ControlContents

If you want to write the Last Name field of rsEmployees that you read in the last section, for example, you could write:

rsEmployees![Last Name] = txtLastName.Text

You would typically write a general procedure to write controls to their corresponding fields, with one line of code similar to the preceding example for each control-field assignment (see Listing 8.6 in the section titled "Updating a Record"). You could call this procedure as the first step in saving data from controls in the Recordset's underlying data.

The second phase of writing to a record requires the use of the Recordset's Update method. This phase is discussed in the following section, "Updating a Record."

See Also


<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © | All Rights Reserved