Clicking on this button after Parent opens results in an error (see above), but if you click on one of the plus-symbols in Child and then click on the button the code would execute without the 2455 error since in this case GrandChild was made visible before the GrandChild.Form access was executed. Hi, I'm having trouble with the following code: Private Sub CustomerIDDblClick(Cancel As Integer) Dim objAccess As Object Dim Pathstring As String Dim cmdForm As Object Dim OpenedForm As Object Dim FormName As String Dim objColForms As Access.Forms Dim numForms As Long Pathstring 'c:\DB-FE\DB-FE.mdb' Set objAccess CreateObject('Access. Let's say you put a button on Parent which executes the code you currently have in your Child.Form_Load sub. In this example each line of the Child datasheet would have a plus-symbol which allows to show GrandChild. In this case any access to GrandChild.Form results in a 2455 runtime error since GrandChild is not shown. Parent presents Child as a datasheet thus GrandChild is not not shown when Parent opens. Let's say Parent has an 1:n relationship to Child and Child has an 1:n relationship to GrandChild. In other words GrandChild has to pull the information (from Child or Parent) and change itself instead of Child pushing the information down to GrandChild by changing GrandChild. Whenever GrandChild loads it can access everything from Child ( Me.Parent.Form) or even Parent ( Me.). Move the code of Child.Form_Load, which accesses GrandChild.Form, into GrandChild.Form_Load. Since I assume that in your case GrandChild is visible if you open Child (without opening Parent) but GrandChild is not visible when you open Parent, I would suggest the following solution without changing your UI: Thus, if you want to execute the code in Child.Form_Load, you have to make sure that GrandChild is visible when Parent opens. Generally the Form property of a subform control gets a "valid reference" only after the subform is shown. I will use Parent, Child, and GrandChild for referring to the respective forms (not the data sources). I could probably write code to work around the problem if there was a way for the grandchild form to know which of the instances it is being loaded as, but as far as I am aware, that isn't possible. If it's relevant, the actual structure of the forms is a bit more complicated, with the grandchild form appearing multiple times (under different control names) in the child form, like this: |-|Įliminating all but one of the grandchild forms does not fix the problem. Does anyone know what might be causing this? I made a test case in a new database and it worked fine, so I'm leaning towards there being something in the legacy code I inherited with the database (which, I've been told, goes back 18 years to a pre-Access database system) that is causing the problem, but I figured I'd check here to see if any of you might know a work-around. I can access any property of the grandchild form except the Form property without throwing any errors. Run-time error '2455': You entered an expression that has an invalid reference to the property Form/Report. When I view the parent form, I get the error: When I view the child form, everything works properly. In the 'Form_Load' sub of the child form, I set some properties of the grandchild (form header, row source, and control logic). When ‘MS Office Security Options’ dialog box opens, click on Enable this content and then click OK.I have three forms in an Access 2003 database (developing in Access 2007) that sit in a parent -> child -> grandchild relationship.From the ‘Security Warning’ message bar, click on Options. The database will be disabled as soon as you initiate a ‘Close Database’ command. This will enable the database only for the current session. Method 1 – Enable the Database for Current Session Note: Before trying these methods, you must first determine if you can trust the database. To fix the Access macro error 2950, try enabling the database by following any of these methods: Methods to Troubleshoot Microsoft Access Database Error 2950 In the Disabled mode, executable content is disabled. By default, Access opens databases that are not trusted in the Disabled mode. The primary reason behind the occurrence of this error is that the database from which the macro is run is not trusted by MS Access. MS Access Error 2950 is received when a macro calling a Visual Basic for Applications (VBA) function is run in MS Access database 2007 or higher. Fig 1 – MS Access Macro Error 2950 Primary Reason Behind Access Database Error 2950
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |