I work on an Access 2003 application that my client wants to convert to Access 2010. Once I converted it, one of the forms, when the code tries to open it, gives me a "run-time error 2501 OpenForm action was canceled. " I have a number of other forms that use the same public call and works fine. But for this particular form it doesn't. The form contains a treeview, subform and tab structure. I haven't changed any code since the conversion although I did notice that a couple of library references are no longer there (DAO 3.6 Object library and Windows common controls (SP6)). In there place, I'm using the Office 14.0 Access database engine Object library
Here's the code:
Public Sub SwitchFormCall(NewForm As String, CallingForm As String, CloseMe As Boolean, ReturnToMe As Boolean, Optional Dialog As Boolean)
Dim c As Collection
If switchFormCurrentCallCol Is Nothing Then
Set switchFormCurrentCallCol = New Collection
End If
Set c = switchFormCurrentCallCol
If Not CloseMe Then
c.Add Forms.item(CallingForm), "SF:Form" 'this puts the actual form object in the collection.
End If
c.Add CallingForm, "SF:CallingFormName"
c.Add NewForm, "SF:CalledFormName"
c.Add CloseMe, "SF:CloseMe"
c.Add ReturnToMe, "SF:ReturnToMe"
If switchFormStack.count = 0 Then
switchFormStack.Add c
Else
switchFormStack.Add c, , 1 'add c to SwitchForm collection before 1
End If
'clear switchform calling collection
Set switchFormCurrentCallCol = Nothing
If Dialog Then
DoCmd.OpenForm NewForm, acNormal, , , , acDialog
Else
DoCmd.OpenForm NewForm, acNormal
End If
If CloseMe Then
DoCmd.Close acForm, CallingForm
End If
Close
End Sub
Any ideas as to why a particular form won't work now in Access 2010?