![]() |
Refer to combox from activecontrol name
Hi All,
In a userform with rows of comboboxes and textboxes, after exiting a textbox, if there is nothing in it, and there is nothing in a combobox to it's immediate left then "nothing", else do "this". What I'm trying to do is with the ActiveControl name, I can ID the cbx to the left, then check the cbx's value, and do this or that. This is what I wrote, but I'm stumped. With frm_tech_lv Dim NameOfActiveControl As String NameOfActiveControl = ActiveControl.Name Dim CbxLvCtrlNm As String CbxLvCtrlNm = "frm_tech_lv.cbx_tpl_" & Mid(NameOfActiveControl, 9, 4) & "_lc" & Right(NameOfActiveControl, 1) Dim cbx As ComboBox Set cbx.Name = CbxLvCtrlNm If ActiveControl.Value = "" And cbx = "" Then Else MsgBox "From time needed." Exit Sub End If End With Any and all suggestions would be greatly appreciated. Thanks. |
Refer to combox from activecontrol name
Maybe
With frm_tech_lv Dim NameOfActiveControl As String Dim CbxLvCtrlNm As String Dim cbx As Control NameOfActiveControl = ActiveControl.Name CbxLvCtrlNm = "frm_tech_lv.cbx_tpl_" & Mid(NameOfActiveControl, 9, 4) _ & "_lc" & Right(NameOfActiveControl, 1) Set cbx = me.controls(CbxLvCtrlNm) If ActiveControl.Value = "" And cbx.value = "" Then Else MsgBox "From time needed." Exit Sub End If End With BigPig wrote: Hi All, In a userform with rows of comboboxes and textboxes, after exiting a textbox, if there is nothing in it, and there is nothing in a combobox to it's immediate left then "nothing", else do "this". What I'm trying to do is with the ActiveControl name, I can ID the cbx to the left, then check the cbx's value, and do this or that. This is what I wrote, but I'm stumped. With frm_tech_lv Dim NameOfActiveControl As String NameOfActiveControl = ActiveControl.Name Dim CbxLvCtrlNm As String CbxLvCtrlNm = "frm_tech_lv.cbx_tpl_" & Mid(NameOfActiveControl, 9, 4) & "_lc" & Right(NameOfActiveControl, 1) Dim cbx As ComboBox Set cbx.Name = CbxLvCtrlNm If ActiveControl.Value = "" And cbx = "" Then Else MsgBox "From time needed." Exit Sub End If End With Any and all suggestions would be greatly appreciated. Thanks. -- Dave Peterson |
Refer to combox from activecontrol name
Hi Dave,
Thankyou! You're a life saver! |
All times are GMT +1. The time now is 03:02 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com