Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Userform Blank/empty textboxes

  Asked By: Abbie    Date: Mar 04    Category: MS Office    Views: 2705
  

I need to stop userform textboxes being left empty. The form is
only used for initial data input to be appended to a list.

I found that this does not work when the validation is in the
beforeupdate event where I am testing for other possible invalid
inputs.

Am I correct in assuming that this validation should therefore be
placed in the controls_Exit event.

Should I put all the validation in the exit event.

As a test I have used the following in the exit event and that seems
to work.

If myControlname.Value = "" Then
MsgBox "Cannot be left as a blank entry"
Cancel = True
End If

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Wilbert Patterson     Answered On: Mar 04

Instead of using event  code to validate each field as it is edited, why not wait
until the user indicates (by clicking an 'OK' or 'Add record' button or
whatever) that the data  should be appended to the list? Then validate every
field before appending the data. I do this with a single (lengthy) validation
function that notifies the user of the first error encountered and ultimately
returns TRUE if no errors were found  or FALSE if any errors were found. Also, if
the user quits the session (closes the form, etc.) before attempting to commit
the record, no effort is spent validating data that won't be used.

Hope this helps,

 
Answer #2    Answered By: Faeezah Khan     Answered On: Mar 04

Your validation  should be done when the user clicks the Save or OK button -
whatever actually causes the information to be used, and presumably also
causes the form  to close.

You can do validation on field changes earlier if you like - although I
prefer not to. (I'd rather let the user do a visual scan and fix problems,
prior to hitting OK.)

 
Didn't find what you were looking for? Find more on Userform Blank/empty textboxes Or get search suggestion and latest updates.




Tagged: