VBA code works on one machine but not other

lution

Registered User.
Local time
Today, 11:29
Joined
Mar 21, 2007
Messages
114
I have Access 2007 (32bit) on one machine and Access 2010 (32 bit) on another. I've written some code to save the column settings on 3 datasheet subforms. If I create a .accde on the 2007 machine from the .accdb on that machine everything works fine. If I copy the .accdb from the 2007 machine to the 2010 machine and create a 2010 .accde, everything works fine. If I try to create the .accde on the 2007 machine and copy it to the 2010 machine, the subforms are empty. The VBA compiles on both machines and the application runs with no other errors so I don't think its a missing reference.

What is even weirder, is it is updating the display for one of the subforms but not the other 2 in .accde mode (updates all 3 in .accdb mode).

In the on_close of the main form I have :
Code:
Private Sub SaveColumnOrders()
    Call SaveTransmitHistoryColumnOrders
    Call SaveTransactionsColumnOrder
    Call SaveDefendantSummaryColumnOrders
End Sub

Private Sub SaveDefendantSummaryColumnOrders()
    Dim FormColumnOrders As clsColumnOrders
    Set FormColumnOrders = New clsColumnOrders
    FormColumnOrders.AddSet Me.frmDefendantSummary2.Name, Me.frmDefendantSummary2.Form.Controls
    FormColumnOrders.Save
End Sub

Private Sub SaveTransactionsColumnOrder()
    Dim FormColumnOrders As clsColumnOrders
    Set FormColumnOrders = New clsColumnOrders
    FormColumnOrders.AddSet Me.subfrmFinancialTransactions.Name, Me.subfrmFinancialTransactions.Form.Controls
    FormColumnOrders.Save
End Sub

Private Sub SaveTransmitHistoryColumnOrders()
    Dim FormColumnOrders As clsColumnOrders
    Set FormColumnOrders = New clsColumnOrders
    FormColumnOrders.AddSet Me.subfrmTransmitHistory.Name, Me.subfrmTransmitHistory.Form.Controls
    FormColumnOrders.Save
End Sub

In the on_load of the main form I have the following:
Code:
Private Sub SetColumnSettings()
    Call SetDefendantSummaryColumnSettings
    Call SetTransactionsColumnSettings
    Call SetCaseTransmitHistorysubformColumnSettings
    Me.Repaint
End Sub

Private Sub SetDefendantSummaryColumnSettings()
Dim FormColumnOrders As clsColumnOrders
    Set FormColumnOrders = New clsColumnOrders
    FormColumnOrders.Load gCurrentUser, Me.frmDefendantSummary2.Name
    FormColumnOrders.SetFormDisplayOrder Me.frmDefendantSummary2.Form.Controls
End Sub

Private Sub SetTransactionsColumnSettings()
Dim FormColumnOrders As clsColumnOrders
    Set FormColumnOrders = New clsColumnOrders
    FormColumnOrders.Load gCurrentUser, Me.subfrmFinancialTransactions.Name
    FormColumnOrders.SetFormDisplayOrder Me.subfrmFinancialTransactions.Form.Controls
End Sub

Private Sub SetCaseTransmitHistorysubformColumnSettings()
Dim FormColumnOrders As clsColumnOrders
    Set FormColumnOrders = New clsColumnOrders
    FormColumnOrders.Load gCurrentUser, Me.subfrmTransmitHistory.Name
    FormColumnOrders.SetFormDisplayOrder Me.subfrmTransmitHistory.Form.Controls
End Sub

I have 2 class modules that I added, one for an instance of a set of column properties, and another that is a list of column properties. I can post all the code if necessary but it basically takes the controls from the form as input and stores it in a table in the database on close and reverses the process on open.

The data is written to the table in the database on close when in .accdb mode or in .accde mode when the .accde was created on that machine.

I can't figure out why putting the accdb on each machine and then creating the .accde from there works but creating the .accde on the 2007 machine and using it elsewhere doesn't. I have clients that use everything from 2007 through 2015 so I need to start at the lowest common denominator.

Since it is failing in the .accde I can't do breakpoints and I'm at a loss for what to check.

Thoughts?
 
Here is my clsColumnOrder code in case it matters:
Code:
' Module     : clsColumnOrder
' Description:
' Procedures : Get UserID() As Long
'              Let UserID(ByVal lUserID As Long)
'              Get FormName() As String
'              Let FormName(ByVal sFormName As String)
'              Get ColumnName() As String
'              Let ColumnName(ByVal sColumnName As String)
'              Get Width() As Long
'              Let Width(ByVal lWidth As Long)
'              Get Order() As Long
'              Let Order(ByVal lOrder As Long)
'              Get IsHidden() As Boolean
'              Let IsHidden(ByVal bIsHidden As Boolean)
'              Get TabIndex() As Long
'              Let TabIndex(ByVal lTabIndex As Long)
'              Clone() As clsColumnOrder
' Modified   :
' 03/01/13 s Cleaned with Total Visual CodeTools
'
' --------------------------------------------------
Option Compare Database
Option Explicit

Private m_UserID As Long
Private m_FormName As String
Private m_ColumnName As String
Private m_Width As Long
Private m_Order As Long
Private m_IsHidden As Boolean
Private m_TabIndex As Long


Public Property Get UserID() As Long
    ' Comments:
    ' Params  :
    ' Returns : Long
    ' Modified:

    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

    UserID = m_UserID

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Property

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Property

Public Property Let UserID(ByVal lUserID As Long)
    ' Comments:
    ' Params  : lUserID
    ' Modified:

    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

    If Len(lUserID) > 0 Then
        m_UserID = lUserID
    Else
        m_UserID = 0
    End If

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Property

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Property

Public Property Get FormName() As String
    ' Comments:
    ' Params  :
    ' Returns : String
    ' Modified:

    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

    FormName = m_FormName

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Property

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Property

Public Property Let FormName(ByVal sFormName As String)
    ' Comments:
    ' Params  : sFormName
    ' Modified:

    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

    If Len(sFormName) > 0 Then
        m_FormName = sFormName
    Else
        m_FormName = ""
    End If

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Property

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Property

Public Property Get ColumnName() As String
    ' Comments:
    ' Params  :
    ' Returns : String
    ' Modified:

    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

    ColumnName = m_ColumnName

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Property

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Property

Public Property Let ColumnName(ByVal sColumnName As String)
    ' Comments:
    ' Params  : sColumnName
    ' Modified:

    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

    If Len(sColumnName) > 0 Then
        m_ColumnName = sColumnName
    Else
        m_ColumnName = ""
    End If

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Property

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Property

Public Property Get Width() As Long
    ' Comments:
    ' Params  :
    ' Returns : Long
    ' Modified:

    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

    Width = m_Width

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Property

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Property

Public Property Let Width(ByVal lWidth As Long)
    ' Comments:
    ' Params  : lWidth
    ' Modified:

    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

    If Len(lWidth) > 0 Then
        m_Width = lWidth
    Else
        m_Width = 0
    End If

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Property

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Property

Public Property Get Order() As Long
    ' Comments:
    ' Params  :
    ' Returns : Long
    ' Modified:

    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

    Order = m_Order

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Property

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Property

Public Property Let Order(ByVal lOrder As Long)
    ' Comments:
    ' Params  : lOrder
    ' Modified:

    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

    If Len(lOrder) > 0 Then
        m_Order = lOrder
    Else
        m_Order = 0
    End If

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Property

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Property

Public Property Get IsHidden() As Boolean
    ' Comments:
    ' Params  :
    ' Returns : Boolean
    ' Modified:

    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

    IsHidden = m_IsHidden

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Property

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Property

Public Property Let IsHidden(ByVal bIsHidden As Boolean)
    ' Comments:
    ' Params  : bIsHidden
    ' Modified:

    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

    m_IsHidden = bIsHidden

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Property

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Property

Public Property Get TabIndex() As Long
    ' Comments:
    ' Params  :
    ' Returns : Long
    ' Modified:

    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

    TabIndex = m_TabIndex

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Property

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Property

Public Property Let TabIndex(ByVal lTabIndex As Long)
    ' Comments:
    ' Params  : lTabIndex
    ' Modified:

    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

    If Len(lTabIndex) > 0 Then
        m_TabIndex = lTabIndex
    Else
        m_TabIndex = 0
    End If

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Property

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Property

Public Function Clone() As clsColumnOrder
    ' Comments:
    ' Params  :
    ' Returns : clsColumnOrder
    ' Modified:

    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

    Set Clone = New clsColumnOrder
    With Clone
        .ColumnName = Me.ColumnName
        .FormName = Me.FormName
        .IsHidden = Me.IsHidden
        .Order = Me.Order
        .TabIndex = Me.TabIndex
        .UserID = Me.UserID
        .Width = Me.Width
    End With

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Function

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Function

And the wrapper around it so I can do a list of them (clsColumnOrders):
Code:
' Module     : clsColumnOrders
' Description:
' Procedures : Get Count() As Long
'              Remove(strKey As Variant)
'              Get Item(strKey As Variant) As clsColumnOrder
'              Initialize()
'              class_terminate()
'              Clear()
'              Add(ByVal NewColumnOrder As clsColumnOrder, Optional BeforeSpot As Long = -1, Optional AfterSpot As Long = -1)
'              AddSet(ByVal FormName As String, ByRef ControlList As Controls)
'              Cleanup()
'              NewEnum() As IUnknown
'              Save()
'              Load(ByVal cUser As Long, ByVal cForm As String)
' Modified   :
' 03/01/13 s Cleaned with Total Visual CodeTools
'
' --------------------------------------------------
Option Compare Database
Option Explicit

Private Const PersistTable = "ztblUserColumnOrders"

Private m_ColumnCollection As Collection

Public Property Get Count() As Long
    ' Comments:
    ' Params  :
    ' Returns : Long
    ' Modified:

    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

    Count = m_ColumnCollection.Count

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Property

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Property

Public Sub Remove(strKey As Variant)
    ' Comments:
    ' Params  : strKey
    ' Modified:

    ' removes a member from the collection
    m_ColumnCollection.Remove strKey

    On Error Resume Next

    On Error GoTo 0

End Sub

Public Property Get Item(strKey As Variant) As clsColumnOrder
    ' Comments:
    ' Params  : strKey
    ' Returns : clsColumnOrder
    ' Modified:

    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

    Set Item = m_ColumnCollection(strKey)

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Property

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Property

Private Sub Class_Initialize()
    ' Comments:
    ' Params  :
    ' Modified:

    ' instantiate the new collection
    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

    Set m_ColumnCollection = New Collection

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Sub

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd
End Sub

Public Sub Class_Terminate()
    ' Comments:
    ' Params  :
    ' Modified:

    ' destroys the collection
    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd
Dim AColumnOrder As clsColumnOrder

    For Each AColumnOrder In m_ColumnCollection
        m_ColumnCollection.Remove AColumnOrder.ColumnName
    Next
    Set m_ColumnCollection = Nothing

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Sub

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Sub

Public Sub Clear()
    ' Comments:
    ' Params  :
    ' Modified:


    ' clears the collection and destroys all the objects
    ' then recreates it.
    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

    Set m_ColumnCollection = Nothing
    Set m_ColumnCollection = New Collection

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Sub

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Sub

Public Sub Add(ByVal NewColumnOrder As clsColumnOrder)
    ' Comments:
    ' Params  : NewColumnOrder
    '           BeforeSpot
    '           AfterSpot
    ' Modified:

    ' add a new columnorder to the collection
    ' can send the spot to insert into using either the before or after spots
    ' send a the insert location to put it into.
    ' must be within the confines of the list
    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

    m_ColumnCollection.Add NewColumnOrder, NewColumnOrder.ColumnName

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Sub

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Sub

Public Sub AddSet(ByVal FormName As String, ByRef ControlList As Controls)
    ' Comments:
    ' Params  : FormName
    '           ControlList
    ' Modified:

    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

Dim MyCol As clsColumnOrder
Dim ctl As control

    'If Nz(gCurrentUser) > 0 And Len(FormName) > 0 Then
    If Len(FormName) > 0 Then
        For Each ctl In ControlList
            If (Left(ctl.Name, 3) = "col") Then
                Set MyCol = New clsColumnOrder
                MyCol.FormName = FormName
                MyCol.UserID = gCurrentUser
                MyCol.ColumnName = ctl.Name
                MyCol.IsHidden = ctl.ColumnHidden
                MyCol.Width = ctl.ColumnWidth
                MyCol.Order = ctl.ColumnOrder
                MyCol.TabIndex = ctl.TabIndex
                Me.Add MyCol
                Set MyCol = Nothing
            End If
        Next
    End If

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Sub

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Sub

Private Sub Cleanup()
    ' Comments:
    ' Params  :
    ' Modified:

' remove all the records for this user & form from the database
' so we can add new rows
    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

Dim strSQL As String
Dim cUser As Long
Dim cForm As String
Dim cFirstCol As clsColumnOrder

    Set cFirstCol = Me.Item(1).Clone
    cUser = cFirstCol.UserID
    cForm = cFirstCol.FormName

    If Len(cUser) > 0 And Len(cForm) > 0 Then
        ' make sure we have a userID and form since we are getting rid of all rows for the form and user
        ' don't want to get rid of every instance of a form or all forms for a user
        strSQL = "delete * from " & PersistTable & " where UserID = " & cFirstCol.UserID & " and FormName = " & Chr(34) & cFirstCol.FormName & Chr(34) & ";"
        DoCmd.SetWarnings False
        DoCmd.RunSQL strSQL
        DoCmd.SetWarnings True
    End If


    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Sub

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Sub

Public Function NewEnum() As IUnknown
    ' Comments:
    ' Params  :
    ' Returns : IUnknown
    ' Modified:

    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

        Set NewEnum = m_ColumnCollection.[_NewEnum]

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Function

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Function

Public Sub Save()
    ' Comments:
    ' Params  :
    ' Modified:

    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim myColOrder As clsColumnOrder
Dim lngCount As Long

    ' make sure we don't end up with duplicate rows
    Call Cleanup

    Set db = CurrentDb
    Set rst = db.OpenRecordset(PersistTable)

    If Me.Count > 0 Then
        For lngCount = 1 To m_ColumnCollection.Count
            Set myColOrder = m_ColumnCollection.Item(lngCount)
            rst.AddNew
            With rst
                !UserID = myColOrder.UserID
                !FormName = myColOrder.FormName
                !ColumnName = myColOrder.ColumnName
                !Width = myColOrder.Width
                !displayorder = myColOrder.Order
                !IsHidden = myColOrder.IsHidden
                !TabOrder = myColOrder.TabIndex
                .Update
            End With
        Next
    End If

    rst.Close
    Set rst = Nothing
    Set db = Nothing

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Sub

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Sub

Public Sub Load(ByVal cUser As Long, ByVal cForm As String)
    ' Comments:
    ' Params  : cUser
    '           cForm
    ' Modified:

    'TVCodeTools ErrorEnablerStart
    On Error GoTo PROC_ERR
    'TVCodeTools ErrorEnablerEnd

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
Dim MyCol As clsColumnOrder
' Dim ctl As control

    strSQL = "select * from " & PersistTable & " where UserID = " & cUser & " and FormName = " & Chr(34) & cForm & Chr(34) & " Order By DisplayOrder;"

    Set db = CurrentDb
    Set rst = db.OpenRecordset(strSQL, , dbReadOnly)

    If Not rst.EOF And Not rst.BOF Then
        rst.MoveFirst
        Do While Not rst.EOF
            ' get the data out of the table and add it to the collection
            Set MyCol = New clsColumnOrder
            With rst
                MyCol.UserID = !UserID
                MyCol.FormName = !FormName
                MyCol.ColumnName = !ColumnName
                MyCol.Width = !Width
                MyCol.Order = !displayorder
                MyCol.IsHidden = !IsHidden
                MyCol.TabIndex = !TabOrder
            End With
            Me.Add MyCol
            Set MyCol = Nothing
            rst.MoveNext
        Loop
    End If

    rst.Close
    Set rst = Nothing
    Set db = Nothing

    'TVCodeTools ErrorHandlerStart
PROC_EXIT:
    Exit Sub

PROC_ERR:
    err.Raise err.Number
    'TVCodeTools ErrorHandlerEnd

End Sub

Public Sub SetFormDisplayOrder(ControlList As Controls)
Dim myColOrder As clsColumnOrder
Dim lngCount As Long
Dim CurrentControl As control

    If Me.Count > 0 Then
        For lngCount = 1 To m_ColumnCollection.Count
            Set myColOrder = m_ColumnCollection.Item(lngCount)
            Set CurrentControl = ControlList(myColOrder.ColumnName)
            If (CurrentControl Is Nothing) Then
            Else
                CurrentControl.ColumnHidden = myColOrder.IsHidden
                CurrentControl.ColumnWidth = myColOrder.Width
                CurrentControl.ColumnOrder = myColOrder.Order
                CurrentControl.TabIndex = myColOrder.TabIndex
            End If
            
            Set CurrentControl = Nothing
            Set myColOrder = Nothing
        Next
    End If

End Sub
 
I have rarely worked with accde files and never with mixed Access versions.

It's harder debugging compiled databases because you can't set breakpoints. Accordingly, I'd be using msgboxes to show the values of various objects before and after events eg what is datasource of a subform before opening the parent form and after.

Firstly, I'd be trying to see if the accdb files open on both Access versions.
 
Just a small point. You say "I don't think its a missing reference".

I suggest you check the references in both accdb files. Not just that they are ticked ('checked' in US speak) but that they are in the same order (I only recently discovered that makes a difference!)
 
Cronk, yes. If I copy the accdb to the 2010 system it opens and runs fine with no errors.

Dave, Will check the order of the references to confirm they are the same.
 
The thought occurs to me that with run-time, certain operations are not going to work. They are unlikely to be present in a production system, of course, but just to be sure: Do you ever have any code that tries to diddle with a form by opening in design mode? Like I said, you probably don't, but that is something that might not work in design mode if you had it.
 
Posted the code in my first reply but here is the code that changes the columns:

Code:
Public Sub SetFormDisplayOrder(ControlList As Controls)
Dim myColOrder As clsColumnOrder
Dim lngCount As Long
Dim CurrentControl As control

    If Me.Count > 0 Then
        For lngCount = 1 To m_ColumnCollection.Count
            Set myColOrder = m_ColumnCollection.Item(lngCount)
            Set CurrentControl = ControlList(myColOrder.ColumnName)
            If (CurrentControl Is Nothing) Then
            Else
                CurrentControl.ColumnHidden = myColOrder.IsHidden
                CurrentControl.ColumnWidth = myColOrder.Width
                CurrentControl.ColumnOrder = myColOrder.Order
                CurrentControl.TabIndex = myColOrder.TabIndex
            End If
            
            Set CurrentControl = Nothing
            Set myColOrder = Nothing
        Next
    End If

End Sub

Even in the .accde it works properly for the call to SaveDefendantSummaryColumnOrders. It fails on the other 2. Other 2 are on tabs on the form but I tried moving them off the tabs and it didn't matter.

Tonight I'll setup a empty front end and try it to see if I can reproduce with a smaller sample that I can post here.
 
Figured it out by commenting out the calls to store/set to make sure the accde worked without any of it in there. Then uncommented the first form save and set so only one was happening and copied that accde. It worked. Went to uncomment the second I realized that I had

Set FormColumnOrders = New clsColumnOrders

in each method but I never set it to nothing. Added

Set FormColumnOrders = Nothing

To each set & save method and it all works properly now. Thanks guys.
 
Ah, a simple example of the "Everything I Needed to Know I Learned in Kindergarten" rule. (If you open it, close it. If you take it out, put it away neatly.)

Good sleuthing!
 
Great rule Doc Man, but try telling that to my kids! (and grandkids!) In fact I am still learning it myself!
 
Do you ever have any code that tries to diddle with a form by opening in design mode?
providing the underlying file type is .accdb, code which opens a form in design view makes a change then saves the form will work in a runtime environment. Might as well open the form hidden in design mode because runtime will not display a design view of a form.

If the underlying version is .accde then forms cannot be opened in design view regardless of whether the environment is runtime or full version.
 

Users who are viewing this thread

Back
Top Bottom