Hey,
I am trying to create cascading combo box where when I select the make of a vehicle only models for that make will appears. The code below is what was used. When I select the make on the form "frmVehicleDetails" and click on the dropdown for the model I receive the error "Syntax error in date in query expression 'tblVehicleModel.VehicleModel#". Attached is the file "FuelManagement1.zip" I am working with any help would be appreciated in resolving this issue.
Code:
Option Compare Database
Private Sub cboVehicleMakeName_AfterUpdate()
'Set the Vehicle Modelcombo box to be limited by the selecetd Vehicle Make.
Me.cboVehicleModel.RowSource = "SELECT tblVehicleModel.VehicleModel#, tblVehicleModel.VehicleModel FROM tblVehicleModel " & _
" WHERE VehicleMake# = " & Nz(Me.cboVehicleMakeName) & _
" ORDER BY VehicleModelName"
Me.cboVehicleModel = Null
EnableControls
End Sub
Private Sub EnableControls()
'Clear the combo bozes
If IsNull(Me.cboVehicleMakeName) Then
Me.cboVehicleModel = Null
End If
End Sub
Private Sub Combo6_AfterUpdate()
'Set the Vehicle Modelcombo box to be limited by the selecetd Vehicle Make.
Me.Combo8.RowSource = "SELECT tblVehicleModel.VehicleModel#, tblVehicleModel.VehicleModel FROM tblVehicleModel " & _
" WHERE VehicleMake# = " & Nz(Me.Combo8) & _
" ORDER BY VehicleModel"
Me.Combo8 = Null
EnableControls
End Sub
Private Sub Form_Load()
'When the form loads, enable/disable the combo boxes. Combo boxes are only enabled if the preceeded combo box has a value.
EnableControls
End Sub
Thanks.
Nika