Updating an Existing Record

To update an existing record, you need to build a recordset with exactly one record. This requires that the user select some sort of unique key when identifying the records. After you have opened the recordset, use the .Fields property to change the field in question and then the .Update method to commit the changes to the database.

The earlier example returned a recordset to a blank worksheet and then called a userform frmTransConf. This form uses a simple Userform_Initialize to display the range in a large list box. The list box's properties have the MultiSelect property set to True:

Private Sub UserForm_Initialize()

1 Determine how Records we have FinalRow = Cells(65536, 1).End(xlUp).Row If FinalRow > 1 Then

Me.lbXlt.RowSource = "A2:F" & FinalRow End If

End Sub

After the initialize procedure is run, the unconfirmed records are displayed in a list box. The logistics planner can mark all the records that have been actually sent, as shown in Figure 19.4.

Figure 19.4

This userform displays particular records from the Access recordset. When the buyer selects certain records and then chooses the Confirm button, you'll have to use ADO's Update method to update the Sent field on the selected records.

0 0

Post a comment