[mso] Re: Access 2002: Checking For Nulls On Form Close

  • From: Cathy.Evans@xxxxxxxxx
  • To: mso@xxxxxxxxxxxxx
  • Date: Mon, 14 Jun 2004 09:04:27 -0400

Hi Jim, I'm back to this today.  Copied the code from BeforeUpdate and
pasted to form Unload event handler per A) below.  Works great if user
clicks 'x' to close form, but if they click the buttons I've set up for
them (Home and/or Next) the message telling them which box is blank comes
up, but a second "The Close action was canceled" message also comes up.
Once I click ok, I can finish adding data and close form ok.  How do I get
rid of the 2nd message?

The code for both buttons is the same except for the form they open.  Here
it is:

Private Sub Home_Click()
On Error GoTo Err_Home_Click

    DoCmd.Close

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "SplashScreen"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Home_Click:
    Exit Sub

Err_Home_Click:
    MsgBox Err.Description
    Resume Exit_Home_Click

End Sub

Thank you!  Cathy


                                                                                
                            
                      "Jim Pettit"                                              
                            
                      <j_e_pettit@hotmail      To: <mso@xxxxxxxxxxxxx>          
                            
                      .com>                                                     
                            
                      Sent by:                 cc:                              
                            
                      mso-bounce@freelist                                       
                            
                      s.org                    Subject:  [mso] Re: Access 2002: 
Checking For Nulls On Form  
                      06/10/2004 06:00 PM         Close                         
                            
                      Please respond to                                         
                            
                      mso                                                       
                      ..... 
                                                                                
                            
                                                                                
                            




Cathy--

It appears so, yes. As written, your Next_Click event doesn't 'know'
that the form's BeforeUpdate event has been cancelled, so it goes on its
merry old way unabated. You have a few options:

A) Copy the code from the BeforeUpdate event and paste it into the
form's Unload event handler.

B) Declare a module-level variable (Dim fValid As Integer), using the
BeforeUpdate event to set it to True if all the fields are filled in, or
False if any of them are left blank. Then reference it in the form's
Unload event handler, Cancel *that* event if fValid is False.

One thing I've noticed about you over the months: you sem unafraid to
jump into waters where some fear to tread. I like that... ;-) Anyway,
let us/me know if that doesn't do it for you.

--Jim







-----------------------------------------------------------------------------------------------------
The information transmitted is intended only for the person
or entity to which it is addressed and may contain confidential
and/or privileged material. If you are not the intended recipient 
of this message you are hereby notified that any use, review,
retransmission, dissemination, distribution, reproduction or any
action taken in reliance upon this message is prohibited. If you 
received this in error, please contact the sender and delete the 
material from any computer.  Any views expressed in this message
are those of the individual sender and may not necessarily reflect 
the views of the company.  
-------------------------------------------------------------------------------------------------------

*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to 
mso-request@xxxxxxxxxxxxx with the word "unsubscribe" (without the quotes) in 
the subject line.

Or, visit the group's homepage and use the dropdown menu.  This will also allow 
you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a 
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with 
instructions.  Once you are a member of the files group, you can go here to 
upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************

Other related posts: