How do I make a field mandatory for input?

%3CLINGO-SUB%20id%3D%22lingo-sub-1227177%22%20slang%3D%22en-US%22%3EHow%20do%20I%20make%20a%20field%20mandatory%20for%20input%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1227177%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20having%20an%20issue%20with%20trying%20to%20have%20a%20field%20require%20mandatory%20input.%26nbsp%3B%20Within%20a%20Form%20that%20I%20have%20established%20via%20the%20Customize%20Ribbon--%26gt%3B%20Developer--%26gt%3B%20Forms%20option%20which%20is%20assigned%20to%20the%20Table%20created%20to%20house%20the%20inputted%20data%2C%20I%20need%20for%20a%20field%20to%20require%20mandatory%20input.%26nbsp%3B%20The%20Form%20will%20ask%20for%20a%20Date%2C%20number%20of%20Accounts%2C%20and%20number%20of%20Forms.%20Within%20the%20Forms%26nbsp%3Bfield%20(columns%2Frows%20F8%3AF17)%20I%20need%20for%20the%20user%20to%20be%20required%20to%20input%20a%20value%20of%20Zero%20(0)%20and%20above.%26nbsp%3B%20This%20field%20cannot%20be%20left%20blank.%20Also%2C%20within%20this%20field%20(columns%2Frows%20F8%3AF17)%20I%20have%20assigned%20Data%20Validation%20that%20requires%20the%20number%20in%20this%20field%20to%20not%20exceed%20the%20number%20in%20the%20Accounts%20field%20(columns%2Frows%20E8%3AE17).%26nbsp%3B%20Any%20search%20online%20for%20a%20VBA%20code%20has%20proven%20unhelpful.%20The%20one%20I%20found%20and%20tried%20inputting%20keeps%20returning%20a%20Compile%20error%3A%20Expected%3A%20end%20of%20statement%20response.%26nbsp%3B%20Since%20I%20am%20not%20skilled%20at%20all%20on%20VBA%20I%20am%20at%20a%20standstill.%26nbsp%3BI%20have%26nbsp%3Battached%20a%26nbsp%3Bscreen%20shot%20for%26nbsp%3Breference.%26nbsp%3BCan%20someone%20please%20assist%3F%26nbsp%3B%20I%20would%20greatly%20appreciate%20it.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1227177%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1227339%22%20slang%3D%22en-US%22%3ERe%3A%20How%20do%20I%20make%20a%20field%20mandatory%20for%20input%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1227339%22%20slang%3D%22en-US%22%3EYou%20will%20need%20to%20input%20the%20exception%20in%20the%20vba%20code.%20For%20example%20if%20the%20dimension%20for%20the%20'forms'%20entry%20is%20declared%20as%20'forms'%20then%20you%20would%20need%20to%20add%20a%20line%20of%20code%20something%20like%3CBR%20%2F%3E%3CBR%20%2F%3EIf%20forms.value%20%3D%20%22%22%20Then%3CBR%20%2F%3EMsgbox%20%22You%20must%20enter%20a%20value%20in%20the%20Forms%20field.%22%3CBR%20%2F%3EEnd%20if%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E
Highlighted
Contributor

I am having an issue with trying to have a field require mandatory input.  Within a Form that I have established via the Customize Ribbon--> Developer--> Forms option which is assigned to the Table created to house the inputted data, I need for a field to require mandatory input.  The Form will ask for a Date, number of Accounts, and number of Forms. Within the Forms field (columns/rows F8:F17) I need for the user to be required to input a value of Zero (0) and above.  This field cannot be left blank. Also, within this field (columns/rows F8:F17) I have assigned Data Validation that requires the number in this field to not exceed the number in the Accounts field (columns/rows E8:E17).  Any search online for a VBA code has proven unhelpful. The one I found and tried inputting keeps returning a Compile error: Expected: end of statement response.  Since I am not skilled at all on VBA I am at a standstill. I have attached a screen shot for reference. Can someone please assist?  I would greatly appreciate it.

1 Reply
Highlighted
You will need to input the exception in the vba code. For example if the dimension for the 'forms' entry is declared as 'forms' then you would need to add a line of code something like

If forms.value = "" Then
Msgbox "You must enter a value in the Forms field."
End if