Access Problem After Upgrading from Office 2010 to 2103

NoSmoke

Board Regular
Joined
Dec 1, 2012
Messages
114
My Access program has developed a problem when a particular form is switched to Design View from Form View. I get an "MS Access has Stopped Working" error message (this occurring only when the program is run under Office 2013; 2010 works with no issues). I have narrowed it down to some VBA code, which, if eliminated, removes the problem. The code is (as part of a larger Class Module):

Code:
Public Property Set ControlSetting(ByVal c As Control)
        
        Select Case c.ControlType
            Case acTextBox
                Set cTextBox = c
                    cTextBox.OnEnter = "[Event Procedure]"
                    cTextBox.OnLostFocus = "[Event Procedure]"
           
        End Select
        
End Property

By trial and error, I have found that commenting out the "Set cTextBox = c" statement removes the problem (I then get a VBA error message, not surprisingly I guess, but the Access Stopped Working error is gone).

I didn't write the code and I'm not sure what it is doing but it appears Access 2013 doesn't like it for some reason. Could someone please offer a suggestion as to how to get this to work with 2013?
TIA for any help...
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
I don't see a
dim cTextBox as control
or
dim cTextBox as object
anywhere

do you have
Option Explicit
at the top of your module ?
you should always have Option Explicit

 
Upvote 0
Sorry, I guess I should have included the entire module:

Code:
Option Compare Database
Option Explicit
Private WithEvents cTextBox As TextBox
Private WithEvents cComboBox As ComboBox
Private colFrmControls As Collection
Public Sub CFInitialize(Frm As Form)
Dim c As Control
Dim cCF As clsControlFocus
    Set colFrmControls = New Collection
    
    For Each c In Frm.Controls
        Select Case c.ControlType
            Case acTextBox, acComboBox
                    If c.Enabled And c.Visible Then
                         Set cCF = New clsControlFocus
                         Set cCF.ControlSetting = c
                         colFrmControls.Add cCF
                     End If
            End Select
     Next c
     
End Sub
Public Property Set ControlSetting(ByVal c As Control)
        
        Select Case c.ControlType
            Case acTextBox
                Set cTextBox = c
                    cTextBox.OnEnter = "[Event Procedure]"
                    cTextBox.OnLostFocus = "[Event Procedure]"
            Case acComboBox
                Set cComboBox = c
                    cComboBox.OnEnter = "[Event Procedure]"
                    cComboBox.OnLostFocus = "[Event Procedure]"
        End Select
        
End Property
Private Sub cTextBox_Enter()
     OnEnterSettingsTextBox cTextBox
End Sub
Private Sub cTextBox_LostFocus()
    OnLostFocusSettingsTextBox cTextBox
End Sub
Private Sub cComboBox_Enter()
     OnEnterSettingsComboBox cComboBox
End Sub
Private Sub cComboBox_LostFocus()
    OnLostFocusSettingsComboBox cComboBox
End Sub
Private Sub OnEnterSettingsTextBox(c As Control)
        With c
            .BackColor = RGB(255, 255, 255) 'while
            .ForeColor = RGB(0, 0, 0) 'black
        End With
End Sub
Private Sub OnLostFocusSettingsTextBox(c As Control)
        With c
            
            .BackColor = RGB(214, 223, 236) 'bluish
            .ForeColor = RGB(0, 0, 0)   'black
        End With
End Sub
Private Sub OnEnterSettingsComboBox(c As Control)
        With c
            .BackColor = RGB(255, 255, 255) 'white
            .ForeColor = RGB(0, 0, 0) 'black
        End With
End Sub
Private Sub OnLostFocusSettingsComboBox(c As Control)
        With c
            .BackColor = RGB(214, 223, 236) 'bluish
            .ForeColor = RGB(0, 0, 0)   'black
        End With
End Sub


As I mentioned previously, the code works fine in Access 2010...
 
Last edited:
Upvote 0
Hmm, it now seems you can edit a post for only 10 minutes after posting. Just wanted to add to the above, apologies for the formatting as the "
Code:
" tags seems to remove certain blank lines.
 
Upvote 0

Forum statistics

Threads
1,215,527
Messages
6,125,334
Members
449,218
Latest member
Excel Master

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