Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-28-2018, 03:18 AM
eduzs eduzs is offline Combobox to trigger sub only when item selected by click Windows 10 Combobox to trigger sub only when item selected by click Office 2010 32bit
Expert
Combobox to trigger sub only when item selected by click
 
Join Date: May 2017
Posts: 262
eduzs is on a distinguished road
Default Combobox to trigger sub only when item selected by click

I want my Combobox (userform) to trigger sub ONLY when the item selected by click, not when I type some text and this text corresponds to a value in the list.
Using click event: the problem is that when I type a text that corresponds to a item in the list and try to click in this item, this does not triggers any click event (click, mouseup, mousedown).
Using change event: when I type some text and this text corresponds to a item in the list it triggers the event, even when I was typing only to search items in the list.

Is there any solution for this?
Thank you
__________________
Backup your original file before doing any modification.
Reply With Quote
  #2  
Old 08-28-2018, 04:46 PM
eduzs eduzs is offline Combobox to trigger sub only when item selected by click Windows 10 Combobox to trigger sub only when item selected by click Office 2010 32bit
Expert
Combobox to trigger sub only when item selected by click
 
Join Date: May 2017
Posts: 262
eduzs is on a distinguished road
Default

Apparently there is no solution to this.
I've found a workaround by my self, I add a double " " blank space in each list item so that the value typed in the combo box never matches a value in the drop down list that will ensure that the click event will always work.
In the Change event I alway remove the extra blank spaces to return the combobox value to the actual value.

Thanks!

For collaboration purposes only, here's some parts of my code:

Quote:
Private Sub CB1_Change()

With CB1
If .Value <> "" And .ListIndex <> -1 Then
.Value = Replace(.Value, " ", "")
Call ModMain.RunMySub
End If
End With

End Sub

Private Sub CB1_Keyup(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)

If Right(CB1, 1) = " " And KeyCode = 32 Then KeyCode = 0

If KeyCode = 13 Then
With CB1
If .ListCount = 1 Then
.ListIndex = 0
CB1_Change
End If
End With
Else
Call ModMain.FilterTheComboBox
End If

End Sub
__________________
Backup your original file before doing any modification.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Powerpoint slide table data to combobox item janism22 PowerPoint 0 03-25-2015 05:05 AM
Need macro to fill data from different sheets based on selected item from drop down skorasika Excel Programming 1 03-13-2015 11:25 AM
Combobox to trigger sub only when item selected by click Start Animation with click on multiple trigger (after one another) KaySunset PowerPoint 5 02-26-2015 01:23 AM
Combobox to trigger sub only when item selected by click Selected items in Combobox remain the same when closing and reopen document Attila Word VBA 3 01-29-2015 04:08 AM
Returning a specific value when item is selected from a drop-down list J Press Excel 4 09-10-2012 06:12 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:56 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft