473,782 Members | 2,465 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CLOSE button warning

69 New Member
Using Access '97

Hi there, am wondering how I can incorporate the code for a CLOSE button and also a warning that some fields are missing data. I have the following, but it seems to be wrong. Can someone please give me some help on this??

In regards to the missing fields code, I have associated this with a button and it works, but I also need this to be associated with the CLOSE button.

Thank you VERY MUCH.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command161_Click()
  2. On Error GoTo Err_Command161_Click
  3.  
  4.     DoCmd.Close
  5.  
  6. Exit_Command161_Click:
  7.     Exit Sub
  8.  
  9. Err_Command161_Click:
  10.     MsgBox Err.DESCRIPTION
  11.     Resume Exit_Command161_Click
  12.  
  13.  
  14.     If Nz(Me.Communicated_Date) = "" Then
  15.     MsgBox "MISSING: Communicated Date on 1st tab."
  16.     End If
  17.  
  18.     If Nz(Me.DescribeInjury) = "" Then
  19.     MsgBox "MISSING: Description of Injury on 2nd tab."
  20.     End If
  21.  
  22.     If Nz(Me.BODY_PART_ID) = "" Then
  23.     MsgBox "MISSING: Selection of Body Part on 2nd tab."
  24.     End If
  25.  
  26.     If Nz(Me.F_MEASURES!DATE_COMPL) = "" Then
  27.     MsgBox "MISSING: Actual Completion Date on 6th tab."
  28.     End If
  29.  
  30.     If Nz(Me.F_MEASURES!FINISHED) = "" Then
  31.     MsgBox "MISSING: Finished with Measure? on 6th tab."
  32.     End If
  33.  
  34.     If Nz(Me.F_SME_INVEST_TEAM!SME_NAME) = "" Then
  35.     MsgBox "MISSING: SME Name on 7th tab."
  36.     End If
  37.  
  38.     If Nz(Me.F_SME_INVEST_TEAM!SME_TITLE) = "" Then
  39.     MsgBox "MISSING: SME Title on 7th tab."
  40.     End If
  41.  
  42.     If Nz(Me.INV_TEAM_REVIEWED) = "" Then
  43.     MsgBox "MISSING: Team reviewed this report? on 7th tab."
  44.     End If
  45.  
  46. End Sub
Aug 21 '07 #1
2 1953
JKing
1,206 Recognized Expert Top Contributor
As a you are full member now I must ask that you please enclose your posted code in [code] tags (See How to Ask a Question)

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

MODERATOR.
Aug 22 '07 #2
MMcCarthy
14,534 Recognized Expert Moderator MVP
You are trapping an error on Close. This will only trigger if for some reason the form won't close. These error have specific number identifiers none of which are being trapped by your code. Change your code as follows:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command161_Click()
  2. On Error GoTo Err_Command161_Click
  3. Dim strMissing As String
  4.  
  5.     If Nz(Me.Communicated_Date) = "" Then
  6.     strMissing = strMissing & "Communicated Date on 1st tab." & Chr(13)
  7.     End If
  8.  
  9.     If Nz(Me.DescribeInjury) = "" Then
  10.     strMissing = strMissing & "Description of Injury on 2nd tab." & Chr(13)
  11.     End If
  12.  
  13.     If Nz(Me.BODY_PART_ID) = "" Then
  14.     strMissing = strMissing & "Selection of Body Part on 2nd tab." & Chr(13)
  15.     End If
  16.  
  17.     If Nz(Me.F_MEASURES!DATE_COMPL) = "" Then
  18.     strMissing = strMissing & "Actual Completion Date on 6th tab." & Chr(13)
  19.     End If
  20.  
  21.     If Nz(Me.F_MEASURES!FINISHED) = "" Then
  22.     strMissing = strMissing & "Finished with Measure? on 6th tab." & Chr(13)
  23.     End If
  24.  
  25.     If Nz(Me.F_SME_INVEST_TEAM!SME_NAME) = "" Then
  26.     strMissing = strMissing & "SME Name on 7th tab." & Chr(13)
  27.     End If
  28.  
  29.     If Nz(Me.F_SME_INVEST_TEAM!SME_TITLE) = "" Then
  30.     strMissing = strMissing & "SME Title on 7th tab." & Chr(13)
  31.     End If
  32.  
  33.     If Nz(Me.INV_TEAM_REVIEWED) = "" Then
  34.     strMissing = strMissing & "Team reviewed this report? on 7th tab." & Chr(13)
  35.     End If
  36.  
  37.     If strMissing <> "" Then
  38.         MsgBox "The following are missing:" & Chr(13) & strMissing
  39.         Exit Sub
  40.     Else
  41.         DoCmd.Close
  42.     End If
  43.  
  44. Exit_Command161_Click:
  45.     Exit Sub
  46.  
  47. Err_Command161_Click:
  48.     MsgBox Err.Description
  49.     Resume Exit_Command161_Click
  50.  
  51. End Sub
  52.  
Sep 1 '07 #3

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

Similar topics

2
1698
by: isaphrael | last post by:
I have an unbound form with a textbox with an input mask 00\-00000;;_ Putting some data into the text box and then trying to close it throws the 'didnt match input mask' warning, and if I click ok on that it brings up an error: "You can't save this record at this time." ..."data changes will be lost...want to close...anyway?" It doesn't give me an error number, and I don't have any records to save. What can I do to capture this error?
7
2721
by: mg | last post by:
I need to first open WebForm2 from WebForm1 and then close WebForm1 without the end user having to press an OK button before the close can occur. For example, possibly Response.Write("<script language='javascript'>window.open ('WebForm2.aspx','two','menubar=no');</script>") Is there code that will accomplish this without using 3rd-
4
6326
by: Ron Lautmann | last post by:
I want to close a browser window so I created a Close button that does this: private void Button1_Click(object sender, System.EventArgs e) { RegisterClientScriptBlock("GetData","<Script>close()</Script>"); } But when this runs the browser puts up a dialog box saying: "The web page you are viewing is trying to close the window, od you want to close this window?"
37
6354
by: Jan Tovgaard | last post by:
Hey everyone:) We have a critical problem, which I can see that other people also has ran into. In Internet Explorer 7 it is no longer possible to do a window.close after opening a window, without getting a alert message that ask if u want to close the window. This did NOT happen in Internet Explorer 6, Mozilla firefox or other browsers.
0
1252
by: bmwm3 | last post by:
Hi: New to C#, I have a MainForm (parent) that can potentially have multiple child forms (in a tabbed interface). Mainform has closing event defined for "Close All" (through a menu option) which basically gives user list of all child forms and asks if want to be saved or not. Similarly, each child form has "Close" which gives a warning about closing that specific form without saving.
1
1861
by: KMEscherich | last post by:
Using Access '97 Hi there, am wondering if there is a way to have a CLOSE button on the form and have it NOT CLOSE the form unless all the REQUIRED controls have an entry. I have 3 items I would LOVE to find out about: 1 / I have created a button that I have attached to following code to and it seems to check the fields and it gives me a WARNING that a particular field needs to have an entry if something is missing. This is good, and it...
2
4820
by: Eric | last post by:
Hi, I have a form that requires a save button to be clicked before closing the form. I would like a msgbox to pop up when the button is not clicked before closing. Can someone show me how i would code this? Thanks!
2
2411
by: jmarcrum | last post by:
Hi everyone!! I have a problem. I have a form for entering new data. If the user clicks the button on my frmMain (cmdAdd), the form for entering new data appears. However, IF the user decides NOT to enter any data and click the cancel button instead of the Save button and error pops up. How do I keep this from happening? I've implemented some error checking but still no results. Here's my code... Private Sub cmdCancel_Click() On...
6
3246
by: =?Utf-8?B?UGF1bA==?= | last post by:
I am looking for a java script to close a web form that I can attatch to a button click event. I am using vs2005, c#. Thanks -- Paul G Software engineer.
0
9641
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10313
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10146
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.