473,395 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

how to restric user to close a form

284 100+
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
2 1215
lotus18
866 512MB
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
137 100+
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

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

Similar topics

2
by: Technical Group | last post by:
Friends, Can anybody help me out by sending a piece of C# code showing how to add an active directory user to a particular user group? If the group does not exist, then create it. Thanks in...
10
by: sqlboy2000 | last post by:
Hello all, I have something very simple going on here and I'm scratching my head as to what the problem is. There are 4 items in my project, 2 webforms, a user control, and a module: ...
3
by: rdemyan via AccessMonster.com | last post by:
My application is split into a front end and back end. Each user has their own copy of the front end. There are a few forms I only want to be open for one user at a time. So I've implemented the...
3
by: Ant | last post by:
Hi, Does anybody here know how to test user controls on the fly. I build the user control, as well as the application I am testing it in but the changes made to the user control aren't seen unless...
3
by: hary08 | last post by:
im doing a database for Hospital Admission, I have a log in form which prompt user for a password. The source of log in is to look for the values in my Table tblEmployees and match user name and...
2
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All, I am trying to determine if the user clicked the "x" close button within the controlbox of the form (top right corner - next to minimize and maximize buttons). I am using the...
13
JodiPhillips
by: JodiPhillips | last post by:
G'day, I have a silly and simple problem that I need some guidance with. Due to the way our network is set up, I am unable to use the group permissions for Access and have had to implement log...
5
by: =?Utf-8?B?Q2hyaXM=?= | last post by:
I am showing a form by ShowModal(). I put a button on that form. When a user clicks the button a MsgBox will show with question "do you want to close?" yes/no. How to handle the situation: - user...
7
by: Sin Jeong-hun | last post by:
I have a dialog form which pops up from the main window using the ShowDialog() method. this dialog has no or button, and it has quite a lot of controls on it. Now, I want to close this dialog...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.