View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Zani Zani is offline
external usenet poster
 
Posts: 29
Default UserForms, mandatory completion of fields

I have a series of userforms collecting user information. I now want to make
some of the fields on UserForm1 mandatory for completion so I am running the
following code:

Private Sub Userform_queryclose(Cancel As Integer, CloseMode As Integer)

If Len(TextBox1) = 0 Then
MsgBox "please complete all mandatory fields"
Cancel = True

End If

End Sub

However when a mandatory field is missed in userform1 and this code kicks
in, it still shows next Userform that would have been shown had all the
information been collected correctly. At the end of Userform1 I have the
following:

Unload UserForm1
Load UserForm5
UserForm5.Show

How do I stop this next userform from appearing until after all the
mandatory fields have been completed?

--
Zani
(if I have posted here, I really am stuck!)