How It Works

First, you created the Retrieve method of the clsCar class. The Retrieve method is responsible for calling the data access layer to look up a particular car record.

Public Function Retrieve(ByVal VehicleId As Integer) As ADODB.Recordset

'Retrieve the detail record for the car 'from the database

'code to call the data access layer that retrieves the record from 'the database

For illustration purposes, the method includes code to print a message to the Immediate Window to let you know that the method executed.

Debug.Print "clsCar.Retrieve method"

Debug.Print "VehiclelD: " & Vehicleld & " will be retrieved from the database."

End Function

Next, you created the Add method to handle adding a new car record to the database.

Public Sub Add()

'Add the current values in the Car object to the database

'code to call the data access layer that adds the record to the database

Again, the method includes code to print a message to the Immediate Window to let you know the method executed.

Debug.Print "clsCar.Add method"

Debug.Print "New record being added for Vehicleld: " & Me.VehicleIdNumber

End Sub

The Update and Delete methods are created in similar ways. One or more of these methods will be used in later examples. Now turn your attention to events.

0 0

Post a comment