Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Highlight functionality for indication of empty/missing fields

Status
Not open for further replies.

TBL3

Programmer
Jun 6, 2011
50
CA
Hi,

I am working on an application form.
I have many fields that needs to be inputted.
Also, there are mandatory fields that needs to be inputted in order to obtain the final value.

However, my concern is that I wish to code a macro that recognizes all the mandatory fields, and once the mandatory fields are not inputted, the description of the missing field becomes highlighted or change color (indication showing that the field must be filled).

Well, I am lost on how to approach this issue.

Any input or suggestions will be great.


Thanks,
 
Well... What I have done in the past as "one" approach is the following:

I created a table with the text object names, then listed if they were required. I then created a cursor to loop through all these text objects and check the value to confirm it is not NULL or empty string or spaces. If a problem was found I would set focus on the 1st object in the list that had an issue. When the loop finished I would display a text box of the required fields not populated. I denoted the required fields with a "*" in the labels.

You may want to see if color can be used as another means to ID required fields. I have never used color for data sheet subforms, and not sure it can even be done... just a thought...

There are other approaches, and I help this one gives you some direction. Good Luck.

Steve Medvid
IT Consultant & Web Master
 
Hi Steve,

Thanks for the input.
However, I am still confused regards to "creating a cursor to loop through all these text objects ... text box of the required fields not populated."

If you can provide me with an example, that would be great.


Thanks,
tbl3
 
Well... You 1st create a local MS Access DB Table with the names of all the fields on a specific form. Along with the name, you add a field that identifies if field is required (Y/N).

Within the form itself, in my case I had a Save button, and a check on on close event. It is in this code that you create a DAO (or ADO) Record Set. This record set can be referred to as a cursor that stores information in memory. After you create the cursor, you use Do Loop code to loop through each item... Within that code you simply have a check if a Value is filled in for each required field.

Again this is one approach. and their is VBA Coding required to implement.

Perhaps an easier solution is to place a bug IF Statement on the form close event and have IF Statements check if each of the required fields are populated. Then build a big text string to record all fields not populated and show a message box... then use setfocus to set to 1st object not populated.

htwh,


Steve Medvid
IT Consultant & Web Master
 
Thanks Steve,

I do have a better understanding and foundation on how to approach it.

I will see what I can come up with.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top