Popup for Required Field

tbpowers

Board Regular
Joined
Jul 16, 2008
Messages
89
I have a field on my form that, once populated, will close the record and lock down the fields. However there is one field that I want to require before allowing the user to close the record. How would I accomplish this? I would also like to create a message that states "The Qty field must be populated before you can close". Any help will be greatly appreciated.
 

Some videos you may like

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

boblarson

MrExcel MVP
Joined
Nov 14, 2008
Messages
1,964
In the form's BeforeUpdate event put something like:

Code:
If Len(Me.YourTextBoxName & "") = 0 Then
    If MsgBox("You must populate the XXX field before closing.  Do you still want to close?", vbQuestion + vbYesNo, "Close?") = vbYes Then
       Cancel = True
    Else
       Cancel = True
       Me.Undo
    End If
End If
 

tbpowers

Board Regular
Joined
Jul 16, 2008
Messages
89
The code worked fine, but I am wanting to do something a little different. I want to lock a field based on another field.

The field that locks the form holds the initials of the user. When they try to type in their initials I want it to popup the message and require that the qty field be populated before they will be allowed to initial.
 

tbpowers

Board Regular
Joined
Jul 16, 2008
Messages
89
The code below works, I just don't know how to get it to throw the message "Actual Defect Qty must be entered" when a user tries to enter their initials.

Private Sub Disposition_App_QA_Click()
If IsNull(Actual_Defect_Qty) Then
Me.Disposition_App_QA.Locked = True
Else
Me.Disposition_App_QA.Locked = False
End If
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,128,167
Messages
5,629,079
Members
416,364
Latest member
maatpsr

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
Top