WithEvents Access.ComboBox

Mario R. Perez

New member
Local time
Today, 03:35
Joined
May 14, 2020
Messages
29
Good Morning Everyone.

I have this class.

Private WithEvents m_cbo As Access.ComboBox
Private Const OrigenClient As String = "SELECT TblCustomer.id, TblCustomer.FldfullName,tblcustomer.[FldPhone] From TblCustomer where TblCustomer.FldfullName "
'Private Const Fono As String = "FldPhone"

Public Sub load(cbO As Access.ComboBox)
Set m_cbo = cbO
m_cbo.RowSource = OrigenClient
m_cbo.OnGotFocus = "[Event Procedure]"
m_cbo.OnKeyUp = "[Event Procedure]"
End Sub

Private Sub m_cbo__GotFocus()
m_cbo.Dropdown
End Sub



Private Sub m_cbo_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
Exit Sub
End If
If KeyCode = vbKeyDown Or KeyCode = vbKeyUp Then
Else
m_cbo.RowSource = OrigenClient & " LIKE '*" & m_cbo.text & "*'" & "OR" & "(" & m_cbo.Column(2) & " Like '" & "*" & m_cbo.text & "*" & "'));"

m_cbo.Dropdown
End If

End Sub

Before of "
& "OR" & "(" & m_cbo.Column(2) & " Like '" & "*" & m_cbo.text & "*" & "'));"" works perfect but when i want to use it with the "OR.." it fails. you know where the problem is.
Thanks for advance.
 
I would say you need at least a space either side of your OR?
If you followed Pat's advice, that would be obvious.
 
Mario,
Can you post your database with some instructions along with a description of what you want to accomplish?
 
Those emojis don't let me see the code, I hope it's a dot and not an underscore , as suggested by the tooltip.
m_cbo.OnGotFocus
m_cbo_OnGotFocus
Public Sub load(cbO As Access.ComboBox)
Set m_cbo = cbO
m_cbo.RowSource = OrigenClient
m_cbo_OnGotFocus = "[Event Procedure]"
m_cbo_OnKeyUp = "[Event Procedure]"
End Sub

Also, that OR needs some space there.
Rich (BB code):
m_cbo.RowSource = OrigenClient & " LIKE '*" & m_cbo.text & "*'" & "OR" & "(" & m_cbo.Column(2) & " Like '" & "*" & m_cbo.text & "*" & "'));"

Try to add the spaces
Rich (BB code):
m_cbo.RowSource = OrigenClient & " LIKE '*" & m_cbo.text & "*'" & " OR " & "(" & m_cbo.Column(2) & " Like '" & "*" & m_cbo.text & "*" & "'));"

See if that helps.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom