Checking multiple controls for a value

carl6885

Registered User.
Local time
Today, 11:55
Joined
Nov 16, 2011
Messages
82
Hi Guys/Girls

Im having a little trouble and I can not seem to fix it.... i'm tearing my hair out!

I have numerous controls on a form including combo boxes and list boxes which are effectively used to build an sql statement based on values.

I need to check whether any of the controls have a value so that I can append a where clause to a string variable.

For control its working however I have up to 10+ controls on the form and its not working.....

I have tried:

If isnull(me.control) then
'Do something
End if

This works however adding more than one control and it fails, something like this:

if me.control.value = "" OR me.lbControl.listindex = -1 then
'Do something
end if

It fails........ any ideas are welcomed :-) :-)

Thanks in advance.
 
Your Or syntax looks OK, have you tried putting a break point in your Code on the If statement to see what values the controls are actually holding?
 
Hi

Thanks for the advice, didn't think to debug that way..... I did any modified code slightly to:

if not isnull(control) or listbox.listindex <> -1 then

msgbox(something is selected)

end if

this seems to work now no matter how many controls allowing me to add the where clause.

Thanks
 

Users who are viewing this thread

Back
Top Bottom