Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 01-14-2019, 12:21 AM   #1
mba_110
Newly Registered User
 
Join Date: Jan 2015
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
mba_110 is on a distinguished road
Filter form records based on unbound combo box

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

mba_110 is offline   Reply With Quote
Old 01-14-2019, 12:35 AM   #2
isladogs
Part time moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 7,888
Thanks: 98
Thanked 1,963 Times in 1,827 Posts
isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light isladogs is a glorious beacon of light
Re: Filter form records based on unbound combo box

As it's a text field, you need text delimiters

Code:
Me.Recordset.FindFirst "PlateNo = '" & Me.cboPlateNo & "'"
__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Colin
Access 2010 32-bit, Access 2016 32-bit & 64-bit, SQL Server Express 2014, Windows 10,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
isladogs is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Filter Subform results based on Main form unbound field Arvin Forms 13 10-28-2014 02:23 PM
Filter Records based on two combo boxes AgDawg Modules & VBA 5 10-15-2012 07:53 AM
Unbound combo's on form to filter report fraser_lindsay Forms 16 01-12-2009 08:00 PM
Open Form with filter based on unbound Combo Box psatkar Forms 0 06-03-2008 11:18 PM
Permanent filter on form based on unbound text box on another form KyleB Forms 1 09-10-2004 10:11 AM




All times are GMT -8. The time now is 08:26 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World