Scenario: Userform with 5 contact fields at the top made from textboxes (First, Last, Title, Phone, Email,) that I attempting to populate a 5x6 table below that I have created using textboxes (contact1,2,3...) on the same userform. I have a command button I would like to use to populate a contact row and clear the contact fields each time I fill the contact fields and press the button (fill contact fields, press button, populate row 1, fill contact fields, press button, populate row 2.... ). I think I need to incorporate a "control" variable, but I have been writing code now for 14hrs and my brain is not working at peak efficiency. Any help is greatly appreciated! 
Private Sub Image236_Click()
Dim i As Integer
Dim j As Integer
Dim x As Integer
Dim ContactCounter As Integer
For i = 0 To 4
Select Case ContactCounter
Case 0
j = i + 100
For x = 0 To 4
If Me.Controls("TextBox" & i).Value <> "" Then
Me.Controls("TextBox" & j).Value = Me.Controls("TextBox" & i)
Me.Controls("TextBox" & i).Value = ""
End If
Next x
Case 1
j = i + 200
For x = 0 To 4
If Me.Controls("TextBox" & i).Value <> "" Then
Me.Controls("TextBox" & j).Value = Me.Controls("TextBox" & i)
Me.Controls("TextBox" & i).Value = ""
End If
Next x
Case 2
j = i + 300
For x = 0 To 4
If Me.Controls("TextBox" & i).Value <> "" Then
Me.Controls("TextBox" & j).Value = Me.Controls("TextBox" & i)
Me.Controls("TextBox" & i).Value = ""
End If
Next x
Case 3
j = i + 400
For x = 0 To 4
If Me.Controls("TextBox" & i).Value <> "" Then
Me.Controls("TextBox" & j).Value = Me.Controls("TextBox" & i)
Me.Controls("TextBox" & i).Value = ""
End If
Next x
Case 4
j = i + 500
For x = 0 To 4
If Me.Controls("TextBox" & i).Value <> "" Then
Me.Controls("TextBox" & j).Value = Me.Controls("TextBox" & i)
Me.Controls("TextBox" & i).Value = ""
End If
Next x
Case 5
j = i + 600
For x = 0 To 4
If Me.Controls("TextBox" & i).Value <> "" Then
Me.Controls("TextBox" & j).Value = Me.Controls("TextBox" & i)
Me.Controls("TextBox" & i).Value = ""
End If
Next x
Case 6
MsgBox "Max number of contacts for this contractor has been reached"
Exit Sub
End Select
Next i
ContactCounter = ContactCounter + 1
End Sub
Bookmarks