Pinkster69
New Member
- Joined
- Jun 19, 2012
- Messages
- 48
I have a combobox with a list of Extra work Descriptions called "ExtrasComboBox" that allows the user to choose a list of Extra work which is on a Userform called "ExtrasUserForm". I have created a command button called "SaveCommandButton" that on "click" triggers the event! I also have another Userform called "EnterDetailsUserForm" were i have at least 20 textboxes in a Frame called "EnterDetailsExtrasListFrame".
Please Note: The "ExtrasUserForm" is activated by a commandButton on the "EnterDetailsUserForm"
What I am trying to achieve is to figure out how to add the combobox values from the "ExtrasUserForm" to the next empty textbox on the "EnterDetailsUserForm"
I got it to work with the code shown below but my problem is that the code populates all of the 20 Textboxes on the "EnterDetailsUserForm" instead of the first empty TextBox and when I run the code again it re writes all the 20 textBoxes with the New Value rather that the Next empty textbox.
Hope someone can help me out on this?
Please Note: The "ExtrasUserForm" is activated by a commandButton on the "EnterDetailsUserForm"
What I am trying to achieve is to figure out how to add the combobox values from the "ExtrasUserForm" to the next empty textbox on the "EnterDetailsUserForm"
I got it to work with the code shown below but my problem is that the code populates all of the 20 Textboxes on the "EnterDetailsUserForm" instead of the first empty TextBox and when I run the code again it re writes all the 20 textBoxes with the New Value rather that the Next empty textbox.
Hope someone can help me out on this?
Code:
Private Sub SaveCommandButton_Click()
Dim ctl As Control
Dim addWorkDiscription As String
addWorkDiscription = ExtrasComboBox.Value
'Loop through all controls on form
For Each ctl In EnterDetailsUserForm.EnterDetailsExtrasListFrame.Controls
If ctl.Text = vbNullString And ctl.Tag <> vbNullString Then
If Not IsNull(ctl.Value) Then
ctl.Value = addWorkDiscription
End If
End If
Next ctl