473,405 Members | 2,421 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,405 software developers and data experts.

CLOSE button warning

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 1937
JKing
1,206 Expert 1GB
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 Expert Mod 8TB
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
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...
7
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 ...
4
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) {...
37
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,...
0
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)...
1
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...
2
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...
2
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...
6
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
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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,...
0
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...

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.