O anche:
codice:
' ...
' Nel click di un command o dove ti serve...
' ...
dim cCon as control
dim strMsg as string
for each cCon in me.controls
if typeof ccon is textbox then
if ccon.text="" then
select case ccon.name
case text1.name
strMsg=strMsg & vbcrlf & "Text1"
case text2.name
strMsg=strMsg & vbcrlf & "Text2"
' ...
end select
end if
elseif typeof ccon is combobox then
' Qui potresti controllare anche la property ListIndex, che se è -1 non è selezionato nulla nel Combo. Se controlli il Text puoi unire tutto tra ComboBox e TextBox... spero di essermi spiegato ^_^
if ccon.text="" then
select case ccon.name
case combo1.name
strMsg=strMsg & vbcrlf & "Combo1"
'...
end select
end if
end if
next cCon
set cCon = nothing
if strmsg<>"" then
msgbox "I seguenti campi devono essere compilati:" & strMsg,vbinformation,"Attenzione ..."
exit sub
end if
' Qua fai quello che devi fare nel caso i campi siano tutti OK;
' ...
' ...