Is there a way to stop event from trigerring in access? Application.EnableEvents = False

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi,
'm trying to prevent form from closing exept through button click....how can i do this in access? the below code wont work in access form

I only till now know how to set warning to false...
And is there anything like screenupdating to false that can also speed up access codes? Just curious.

Thanks in advance.


Code:
[/FONT]
[FONT=Courier New]'Prevent user from closing with the Close box in the title bar.
    If CloseMode <> 1 Then Cancel = 1
    me.Caption = "The Close box won't work! Click me!"
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Check out the



Hi Smitty, can make it work...still reading but...
can someone help me out!?:)
It does not let me close my form....


Code:
[/FONT]
[FONT=Courier New]Private Sub Form_Close()
Application.Echo False
DoCmd.Close
Application.Echo True
End Sub
Private Sub Form_Unload(Cancel As Integer)
Cancel = True
MsgBox "Use close button to close me..."
End Sub
Private Sub Command14_Click()
Application.Echo False
DoCmd.Close
Application.Echo True
End Sub
 
Upvote 0
In form properties, set the "ControlBox" property to No. There will then be no close button for the user to press and they will have to use your button instead. This is simplest and best, if you want users to use your close button.
 
Upvote 0
Pedie

Access doesn't really have the kind of events you disable in Excel.

Most events will only be triggered because you've created code that triggers them intentionally.

Also, you can't turn offScreenUpdating.

That could be because you don't need it in Access.

If your code is running slowly you really need to look at the code and what it's doing.

You might even be doing something in code that you don't need to do in code.
 
Upvote 0
Thanks Xen, thanks Norie for clarifying...
Xen, that was cool. i like that but i will not like someone to open it in edit mode and change the setting which i think they might do...

So if there is a vba way to stop that then it will be great!:)
Else if there is any way to stop users from changing settings i have set....
 
Upvote 0
So why do you think a user would do this? That's somewhat strange behavior - though if anyone knows enough to know how to do this, they should also know enough to tell if it will break the form or not. You really want to avoid writing so much vba for everything. Lots of vba = lots of errors. Keep it simple.
 
Upvote 0
Yes, i think anyone determined to do this can anyways take care of it...I'll go with less VBA then:biggrin:
Thanks for the support!



 
Upvote 0
Pedie

How about no VBA?

There's plenty if things you can do in Access that don't require code.
 
Upvote 0

Forum statistics

Threads
1,224,565
Messages
6,179,549
Members
452,927
Latest member
rows and columns

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top