-
Aug 22nd, 2016, 11:07 AM
#1
Thread Starter
Junior Member
Access crashing after implementation of custom Class Module for CommandButtons
Desiring to shorten my code and prevent having to create multiple OnClick events for several similar CommandButtons, I decided to try and implement a custom class. I created a new Class Module:
clsButtonGroup
Code:
Option Compare Database
Option Explicit
Public WithEvents ButtonGroup As CommandButton
Private Sub ButtonGroup_Click()
MsgBox "Button " & ButtonGroup.Name & " was clicked!"
End Sub
...and in the module of my main form where the buttons reside I have:
Code:
Option Compare Database
Option Explicit
Dim Buttons() As New clsButtonGroup
Private Sub Form_Load()
'CREATE BUTTON GROUP
Dim btnCount As Integer
Dim ctl As Control
btnCount = 0
For Each ctl In Me.Controls
If TypeName(ctl) = "CommandButton" Then
If ctl.Tag = "filter" Then
btnCount = btnCount + 1
ReDim Preserve Buttons(1 To btnCount)
Set Buttons(btnCount).ButtonGroup = ctl
End If
End If
Next ctl
End Sub
When I launch the form in Form View everything seems to work fine. When I switch to Design View however, I get an EMET error (EMET detected DEP mitigation & Microsoft Access has stopped working) and Access crashes to desktop. When I comment out all the code in the Form_Load event section and repeat the process, Access is fine (no crash). I'm totally new to custom classes so I'm hoping this is just a coding mistake. Any help is much appreciated. Thanks!
-
Aug 23rd, 2016, 01:51 AM
#2
Re: Access crashing after implementation of custom Class Module for CommandButtons
i just tried it out
access 2010
windows10 home
works without problem
do you have the command_click() subs in the form ?
even if it just contains a reminder (')
i also tried without the command_click() subs
did not work, but caused no crash nor error
just did not work
do not put off till tomorrow what you can put off forever
-
Aug 24th, 2016, 10:35 AM
#3
Thread Starter
Junior Member
Re: Access crashing after implementation of custom Class Module for CommandButtons
Thanks for the reply!
Unfortunately it didn't work... I'm dead in the water here. I guess it's just my computer and/or the way my company's IT has it set up. I don't even know what this EMET DEP mitigation junk is. All I know is that it's interfering with the proper functioning of Access.
I already knew it was necessary to set my form button controls' On Click event properties to [Event Procedure] with no actual code behind them except the overarching code mentioned in my first post.
Unfortunately, adding in the...
Code:
Private Sub CommandButton1_Click()
'Just a comment, no code here
End Sub
...bit (which is actually exactly what I was trying to avoid in the first place LOL) didn't do anything.
Thanks for at least trying to help me out though! I appreciate it.
-
Aug 24th, 2016, 01:52 PM
#4
Re: Access crashing after implementation of custom Class Module for CommandButtons
So I googled "EMET DEP" ... it's a security tool from MS built into Windows.
It is what's responsible for plugging holes in IE. Specifically the zero day bug.
It turns out it has caused a number of other applications to hang...
https://redmondmag.com/articles/2014...ty-issues.aspx might be worth the read.
In the case of the article, it was Excel that crashed.
Moar reading: https://www.google.com/search?q=EMET+DEP
-tg
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|