By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,557 Members | 1,406 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,557 IT Pros & Developers. It's quick & easy.

how to restric user to close a form

100+
P: 284
i am using vb6
i want to restirct user to close a form if it has a blank field

for e-g if user did not write name is the box and he tries to close
the form by clicking on the croos button at top right it will be promte
to write name

i konw coding but i want to knowwhere we had to write this code
at unload event of form or teminate or some other
May 25 '08 #1
Share this Question
Share on Google+
2 Replies


lotus18
100+
P: 866
i am using vb6
i want to restirct user to close a form if it has a blank field

for e-g if user did not write name is the box and he tries to close
the form by clicking on the croos button at top right it will be promte
to write name

i konw coding but i want to knowwhere we had to write this code
at unload event of form or teminate or some other
At the Unload event, check for the textbox. If it is empty then pop up a message and Cancel=1.

Rey Sean
May 25 '08 #2

devonknows
100+
P: 137
I think you'll be better off using the query unload method. (Form_QueryUnload) as not only can you stop the code from unloading you can also check how it is being closed wether it is being forcably shutdown by windows, by task manager or by client.

so summet like

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  3.     If Len(Text1.Text) < 1 Or Combo1.ListIndex = -1 Then
  4.         MsgBox "Please insert a value.", vbCritical, "Error"
  5.         Cancel = 1
  6.     End If
  7. End Sub
  8.  
Kind Regards
Devon
May 29 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.