Filter form records based on unbound combo box (1 Viewer)

mba_110

Registered User.
Local time
Today, 05:54
Joined
Jan 20, 2015
Messages
280
Hi

Everyone i am trying to filter the records based on cboPlateNo but unable to succeed, after update of combo box that row records which is on form should filled up with information related to that row.

below is my full code on frmVehicles.

Code:
Option Compare Database

Private Sub BtnSave_Click()
saved = True
   DoCmd.RunCommand (acCmdSaveRecord)
   Me.btnSave.Enabled = False
   saved = False
End Sub

Private Sub cboPlateNo_AfterUpdate()
Me.Recordset.FindFirst "PlateNo = " & Me.cboPlateNo

End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim Response As Integer
If saved = False Then
    Response = MsgBox("Do you want to save the changes on this record?", vbYesNo, "Save Changes?")
    If Response = vbNo Then
       Me.Undo
    End If
    Me.btnSave.Enabled = False
End If

End Sub

Private Sub Form_Dirty(Cancel As Integer)
Me.btnSave.Enabled = True
End Sub


when i click the cboPlateNo button on form it is giving me following errors in afterupdate event of cboPlateno.

1. runtime error 3070'
The microsoft access database engine does not recognize 'BMP' as a valid field name or expression.

2. when i add '" syntax error in string in expression.

my tblvehicles PK is PlateNo (Text) field entry example BMP-501248
 

isladogs

MVP / VIP
Local time
Today, 13:54
Joined
Jan 14, 2017
Messages
18,209
As it's a text field, you need text delimiters

Code:
Me.Recordset.FindFirst "PlateNo = '" & Me.cboPlateNo & "'"
 

Users who are viewing this thread

Top Bottom