I am creating a car rental database. This function is in the OnClick event of the command button to close a car rental contract. Its purpose is to change the status of the car selected from available to rented.
My desired result is to change this routine so that if the user pulls up an existing contract and changes cars for some reason, that the routine is sure to mark the old car as 1 for available and the new car selected as 2 rented.
How should I change the code?
Public Function RentCar()
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * from CarProfileT WHERE CarProfileID=" & Forms!CarRentalContractF!CarProfileCombo)
rs.Edit
rs!StatusID = 2 ' Rented
rs.Update
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Function