UserForm for data entry: force certain controls to be filled in.

Aretradeser

Board Regular
Joined
Jan 16, 2013
Messages
176
Office Version
  1. 2013
Platform
  1. Windows
A Userform, used as a form for data entry, consists of several TextBoxes and ComboBoxes for data entry.
By means of these VBA code lines some of them are forced to be filled in:
CODE:
VBA Code:
    If ComboBox1 = Empty Or ComboBox2 = Empty Or ComboBox3 = Empty Or ComboBox4 = Empty Or ComboBox5 = Empty Or _
        ComboBox6 = Empty Or TextBox1 = Empty Or TextBox2 = Empty Or TextBox3 = Empty Or TextBox4 = Empty Or _
        TextBox5 = Empty Or TextBox6 = Empty Or TextBox7 = Empty Then
        MsgBox "MISSING DATA TO BE FILLED IN !!!", vbExclamation: Exit Sub
    Else

The problem occurs when in the ComboBox1 an element other than "SPAIN" or "PORTUGAL" is selected, which disables the ComboBox6 and the TextBox7; as they cannot be filled in, the data cannot be recorded.
How to solve this obligation to fill in when these controls are disabled (ComboBox6 and TextBox7).
 
That line was not part of my solution

Include an Exit Sub statement & update your line in RED as shown below & see if helps

Rich (BB code):
 If NotComplete Then
        MsgBox "MISSING DATA To BE FILLED IN !!!", vbExclamation, "Entry Required"
    Exit Sub
    End If

      If IsDate(TextBox1) Then fe1 = CDate(TextBox1)

Dave
Thank you, Dave, for your work and effort in solving this problem.
It works very well, but the ComoboBox7 should be included to force it to be filled in as well.
Rich (BB code):
t = Cells(Rows.Count, 2).End(xlUp).Row
            Cells(t + 1, 2) = TextBox6 & " " & TextBox7 & ", " & TextBox5
            Cells(t + 1, 3) = ComboBox5
            Cells(t + 1, 4) = ComboBox6 '
            Cells(t + 1, 5) = ComboBox1 '
            Cells(t + 1, 6) = ComboBox2
            Cells(t + 1, 7) = TextBox1.Value
            Cells(t + 1, 8) = TextBox2.Value
            Cells(t + 1, 9) = ComboBox3
            Cells(t + 1, 10) = ComboBox4
            Cells(t + 1, 11) = 0 + TextBox3
            Cells(t + 1, 12) = TextBox4.Value
            Cells(t + 1, 13) = ComboBox7
            Cells(t + 1, 14) = Right(TextBox1.Value, 4)
 
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Thank you, Dave, for your work and effort in solving this problem.
It works very well, but the ComoboBox7 should be included to force it to be filled in as well.

Cells(t + 1, 13) = ComboBox7
Cells(t + 1, 14) = Right(TextBox1.Value,

Solution was based on your first post which did not show a ComboBox7?

To resolve, DELETE the line shown in BOLD.

Rich (BB code):
For i = 1 To 7

        For a = 1 To 2
          If i > 6 Then a = 2
            With Form.Controls(Choose(a, "ComboBox", "TextBox") & i)
                If .Enabled Then .BackColor = IIf(Len(.Text) > 0, vbWindowBackground, vbYellow)
                If Not NotComplete And .BackColor = vbYellow Then NotComplete = True: .SetFocus
            End With
    
        Next a
        
    Next i

Dave
 
Upvote 0

Forum statistics

Threads
1,214,950
Messages
6,122,428
Members
449,083
Latest member
Ava19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top