Need help with code for 2nd click in a Combobox (2 Viewers)

NeilT123

New member
Local time
Today, 10:16
Joined
Aug 18, 2022
Messages
23
I have a continuous form with a combo box where the row source is a query. I have added the following code so that when I click in the combobox the all of the text is selected so that I can use MajP's FAYT.

Code:
Private Sub cbVarietyID_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
'This code is to highlight the combobox when it is clicked in
   Me.cbVarietyID.SelStart = 0
   Me.cbVarietyID.SelLength = Len(Me.cbVarietyID.Text)
End Sub

This all works well, the issue is that sometimes I need to filter on part of the text in the combobox but the MouseUp code means that the whole of the ComboBox is always selected.

I wondered whether I could set it so that only the 1st click in the Combobox triggers the code and any subsequent clicks just put the cursor in the Combobox but I don't know how to set that up. Any suggestions on how I resolve this would be gratefully received, thank you.
 

Gasman

Enthusiastic Amateur
Local time
Today, 10:16
Joined
Sep 21, 2011
Messages
14,301
I have never had to select all the text to get his FAYT to work?
It is called FAYT for a reason after all?
Perhaps use double click event to select all text?
 

NeilT123

New member
Local time
Today, 10:16
Joined
Aug 18, 2022
Messages
23
On this particular form there is already data in the combobox. If all of the text is not selected and I type "br" for example then the br just gets inserted into the combobox with the existing text. If all text is selected then typing "br" triggers FAYT.
 

Mike Krailo

Well-known member
Local time
Today, 05:16
Joined
Mar 28, 2020
Messages
1,044
On this particular form there is already data in the combobox. If all of the text is not selected and I type "br" for example then the br just gets inserted into the combobox with the existing text. If all text is selected then typing "br" triggers FAYT.
Are you using his latest version of FAYT. It works very well. If you have the combo configured to search from the beginning, then it should auto complete for you. If you have it set so it can search any part of the combo data, then you may have to hit the down arrow after typing "br". In any case FAYTv17 should trigger on the very first character you typed, unless you have modified something.

Update: Well I spoke too soon, there is a bit of an issue with cascading combo box demo. I keep getting "Runtime error: 3075" when moving to the products combo after selecting a supplier. I'm guessing it has to do with the apostrophe's in the supplier names.
 
Last edited:

Users who are viewing this thread

Top Bottom