Access crashing after implementation of custom Class Module for CommandButtons-VBForums
Results 1 to 4 of 4

Thread: Access crashing after implementation of custom Class Module for CommandButtons

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2016
    Posts
    17

    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!

  2. #2
    Fanatic Member
    Join Date
    Jun 2014
    Posts
    982

    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

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2016
    Posts
    17

    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.

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    31,119

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.