VBA - Refer to all controls on a form

Mi

Board Regular
Joined
Sep 19, 2004
Messages
77
hello,
I am trying to find a code. I would like to check all the controls on a form, if null, then msg box to alert. Looking for something like:

if isnull(me.formALLCONTROLS) then
msgBox "no empty fields allowed"
end if
New record is then allowed

BTW, setting the fields on the table level to required has not worked, i have many subforms and it still allows a new record to be added.

Thanks,
Mi
 
This code works but has a problem if the form opens in add mode only and not edit. It also looks at all the past records. I think i am heading in the wrong direction with this problem. Any suggestions on a better way? Main form has currently 10+ fields on it and it continues to grow. Subform has two fields with dropdowns, (select review and then score it).

Table A
ReviewID
Office
ReviewDate
ProjectName

Table B
ReviewTypeID
ReviewType

Table C
ScoreID
Score

Table D
ReviewID
ReviewTypeID
ScoreID


Thanks,
Mi
 
Upvote 0

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Forum statistics

Threads
1,221,905
Messages
6,162,772
Members
451,786
Latest member
CALEB23

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