Check for empty fields in a form

Is there a way to check if a form has an empty field in a form?

What i'm trying to achieve is clicking a button and a message box saying something like
Please enter a value for field a"  Or Not all fields are completed.

I can do it if I check field by field but looking for something to check all fields at one time.

Thanks,
 gil
-GilAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:

place this function in the forms module

Function AllCompleted() as boolean
AllCompleted=true

dim ctl as control
for each ctl in me.controls
   if ctl.controltype=actextbox or ctl.controltype=accombobox then
      if len(ctl)=0 or isNull(ctl) then
         AllCompleted=False
         exit function
      end if
   end if
next
end function
 
call the function in the click event of the button

private sub btn_click()
if AllCompleted=false then
   msgbox "Some fields are not filled out"
end if

end sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
-GilAuthor Commented:
I get error type mismatch and it highlights the = sign.
0
Rey Obrero (Capricorn1)Commented:
which line?
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

-GilAuthor Commented:
if AllCompleted=false then

it highlights the = sign
0
Rey Obrero (Capricorn1)Commented:
for the mean time, delete the lines

if AllCompleted=false then
   msgbox "Some fields are not filled out"
end if


now do a DEBUG>Compile

correct any errors  that may be raised
0
Rey Obrero (Capricorn1)Commented:
also do a compact and repair
tools > database utilities >compact and repair
0
-GilAuthor Commented:
I don't think I can decompile on this computer. Is there any thing else I can try?
0
-GilAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.