Solved Search comboBox on a bounded form (1 Viewer)

Kingz

Member
Joined
Mar 19, 2024
Messages
49
Hi guys,

I have a form with a recordsource

SELECT * FROM TABLE_A WHERE BRANCHES ='OPEN'

This form has several textfields and combo boxes which are bound. I have one combo box cboName bound on the form, which I would like to use as a search field, in the sense that if I type a few letters in the combo box, then my selection from the combo box should only have the names which are possible from the letter typed. Then selecting from one of the few, should give me an updated form with the selected name.So I thought this procedure would make sense in the cbo_Afterupdate

Private Sub cboName_AfterUpdate()


Me.Filter = ""
Me.FilterOn = False

If Len(Me.cboName.Value) > 0 Then
Me.RecordSource = "SELECT Name FROM TABLE_A WHERE Name Like '*" & Me.cboName.Value & "*'"
Me.cboName.Requery
Else
Me.RecordSource = "SELECT Name FROM TABLE_A "
Me.cboName.Requery
End If

If Not IsNull(Me.cboName.Value) Then
Me.Filter = "Name = '" & Me.cboName.Value & "'"
Me.FilterOn = True
End If


End Sub

Now, I get an error 3464(data conflict) on the line Me.FilterOn = True I noticed that with f5 it continues, but the form is not filled, what am I missing? Thanks in advance
 
I believe your combo needs to be unbound, else you will be changing data in that particular record. So you need a Search combo added.
 
Me.RecordSource = "SELECT Name FROM TABLE_A WHERE Name Like '*" & Me.cboName.Value & "*'"
The value property of a combo refers to the BOUND value, NOT the visible string which comes from the RowSource query. It is also NEVER a partial string. It is ALWAYS a complete value when some item is selected.

Code:
Me.RecordSource = "SELECT Name FROM TABLE_A WHERE ThePK = " & Me.cboName
 

Users who are viewing this thread

Top Bottom