Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 478
  • Last Modified:

docmd.closeform

I have a button on my form (created by the wizard) which closes the form.  In the close event of the form the user has the option to cancel the close.  How do I stop access displaying a message advising the user that the docmd action had been cancelled ?  I have tried docmd.setwarnings false but this does not work !!
0
kiddiec
Asked:
kiddiec
1 Solution
 
cekmanCommented:
Prior to the close insert:

On error resume next
0
 
kiddiecAuthor Commented:
I have already tried on error resume next
0
 
guillemsCommented:
The code that I use in my form is:

Private Sub Comando0_Click()
  On Error Resume Next
        DoCmd.Close
End Sub

Private Sub Form_Unload(Cancel As Integer)
  If (vbYes = MsgBox("exit?", vbYesNo)) Then
    Cancel = False
  Else
    Cancel = True
  End If
End Sub

' ---  Comando is the close's button

It's woks, well. But I thing the solution is for cekman.
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
JeroenWCommented:
Try inserting the following code:

sub MyCloseButton_Click()

dim answer as integer

'The vbYesNo doesn't apply to Access 2.0 search help
'on msgbox...
answer = msgbox = "Do you want to exit?",vbYesNo (*)
if answer = vbYes then
    Docmd close
endif

exit sub

Hope it helps,

Jeroen W



0
 
JeroenWCommented:
Oh yeah, you'll have to remove the message from the close event.
Could you tell me what's in the close event? Maybe you can remove the whole thing.

Hope it helps,

Jeroen W



0
 
guillemsCommented:
Sorry, JeroenW. Read the history before answer a question! and read the question too!!!

I think your response is not good, because he asks something different. And I think the answer's CEKMAN IS GOOD, The solution works well.

0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now