I have an ActiveX TextBox with TextBox_Click code behind it such that each character I type triggers another sub to execute which then updates a table by updating a named cell that as a formula in it which drives the table. Then I have a ListBox that has ListFillRange linked to that table. The result is each character I type in the TextBox causes the ListBox to update. This is working fine.
The next thing I put in place was ListBox_Click code so that when I click on an item in the ListBox it updates a Label.Caption then sets ListBox.Value="". This is also working fine.
What I would like to now is have the TextBox clear after the Label.Caption is assigned. The problem is the TextBox clear causes the ListBox to update and the Label then gets the wrong value. This seems odd because the command assign the caption occurs before setting the TextBox = "" which resets the ListBox. But it doesnt seem to matter that the caption assignment occurrs first. The ListBox seems still selected so the update of the TextBox updates the ListBox so the Label gets the wrong value.
Any thoughts are greatly appreciated.
I'm new to ActiveX and I can't figure out or find a workaround.
Thanks in advance for any ideas.
The next thing I put in place was ListBox_Click code so that when I click on an item in the ListBox it updates a Label.Caption then sets ListBox.Value="". This is also working fine.
What I would like to now is have the TextBox clear after the Label.Caption is assigned. The problem is the TextBox clear causes the ListBox to update and the Label then gets the wrong value. This seems odd because the command assign the caption occurs before setting the TextBox = "" which resets the ListBox. But it doesnt seem to matter that the caption assignment occurrs first. The ListBox seems still selected so the update of the TextBox updates the ListBox so the Label gets the wrong value.
Any thoughts are greatly appreciated.
Code:
Private Sub TextBox5_Change()
Call UpdateValues(TextBox5.Value)
End Sub
Code:
Sub UpdateValues(SearchString As String)
Range("mySearchString").Value = SearchString
Range("myStartPosition").Value = Range("myOverwriteProtection").Value
End Sub
Code:
Private Sub ListBox1_Click()
ActiveSheet.OLEObjects("Label33").Object.Caption = ActiveSheet.OLEObjects("ListBox1").Object.Value
ActiveSheet.OLEObjects("ListBox1").Object.Value = ""
'ActiveSheet.OLEObjects("TextBox5").Object.Text = ""
End Sub
I'm new to ActiveX and I can't figure out or find a workaround.
Thanks in advance for any ideas.