MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Required Fields in an Excel Database


Posted by Linda Virgilio on December 31, 2001 8:10 AM

If I am using Excel to maintian a simple database, is there a way you know of that I force required fields. Specifically, I am building a list of contracts which buyers are going to be responsible to maintain. I want them to not be able to enter a row for a contract without entering certain minimal information (Name of supplier, etc.)


Posted by Damon Ostrander on January 01, 2002 12:07 AM

Hi Linda,

The answer is "yes", you can force required fields, but the specifics of how one does this depends on whether you are maintaining the database using custom userforms or whether you are having the buyers enter the contract data directly into worksheet cells--or possibly even both. If you are using the userform approach, then it is simply a matter of checking all the input data controls (usually textboxes) to ensure that all the required data is there when the user clicks on the button that transfers the form's data to the worksheet.

If you are using the direct worksheet method, then you must use the worksheet's SelectionChange event to determine when the user has selected a cell in a different row from the previous selection, and if so check the precious row to make sure all the required data have been entered. If this is your situation, post that fact and I'll respond back with some sample code.

Damon