PDA

View Full Version : Mandatory userform fields



davidboutche
07-30-2009, 08:14 AM
I have a userform that collects data and then a button that actions it. I want to make the fields on that for mandatory.

I assumed that if I put in the button procedure:


IF userform.anyoldfield = null then
msgbox ("Fill it in idiot")
Else 'the usual code goes here
endif

end sub


But that doesn't seem to work... it just runs through the procedure anyway.

The above code was a guess so any help appreciated please.:help

lucas
07-30-2009, 08:39 AM
If Me.TextBox1.Value = "" Then
MsgBox "Fill it in idiot"

davidboutche
07-30-2009, 09:17 AM
Works

Thank you :)

fumei
07-31-2009, 08:15 AM
In other words, you can not use "anyoldfield", but explicit controls.

Textbox1
ComboBox1
CheckBox1

etc. etc.