473,763 Members | 7,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Subform load order and "Invalid reference to the property Form"

I've recently had a nasty problem with the "Invalid reference to the
property Form" error in subforms - nasty because it doesn't seem to
consistently happen to all forms which contain the same structure and
code. Judging by the forums I've researched, it's not an uncommon
error. I'm happy to say I've found a simple solution.

OVERVIEW: I have a main form (no record source) which contains two
subforms. The subforms are not linked, but there is some code in Sub1
which finds a related record in Sub2. The problem is that the
OnCurrent event in Sub1 runs BEFORE Sub2 has loaded, so the first time
it causes an "Invalid reference to the property Form" error. I trap
for the error, then Sub2 loads, and everything works from this point.

CAUSE: subforms are controls, and they run their events before the
Main forms events. So the sequence of events when I open the Main form
is
Sub1: Open, Load, Activate, Current
Sub2: Open, Load, Activate, Current
Main: Open, Load, Activate, Current
The problem occurs in some forms and not others because of the order I
originally placed the subforms on them!

SOLUTION: Sub2 needs to load before Sub1, so that the code in the Sub1
OnCurrent event can reference it. Unfortunately, there is no load
sequence property for subforms, and the Tab Order property doesn't
affect the sequence of loading. However, you can influence the load
order!
1) remove the subforms from Main and save it. For good measure I also
did a compact and repair
2) add Sub2 to Main and Save it. Being paranoid, I did another compact
and repair
3) add Sub1 to Main and Save it. Now it works and I can get rid of the
error trapping!
Nov 13 '05 #1
1 5414
John, thanks for posting the cause and the solution. It is satisfying to
solve, and anyone who searches groups.google.c om will find your solution.

Yes, of course one of the subforms must load before the other, and trying to
refer to the one that has not loaded yet will cause an error. I have a
little disquiet, though at the idea that the load sequence is actually
stable and does not need the error handling. It seems like the kind of thing
that might come back to bite you one day, e.g. if you have to repair a
corruption by importing everything into a new database, or convert to a new
version?

Would it be worthwhile leaving the error-handling for the particular
situation in place?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"John Hunter" <js******@waika to.ac.nz> wrote in message
news:6b******** *************** ***@posting.goo gle.com...
I've recently had a nasty problem with the "Invalid reference to the
property Form" error in subforms - nasty because it doesn't seem to
consistently happen to all forms which contain the same structure and
code. Judging by the forums I've researched, it's not an uncommon
error. I'm happy to say I've found a simple solution.

OVERVIEW: I have a main form (no record source) which contains two
subforms. The subforms are not linked, but there is some code in Sub1
which finds a related record in Sub2. The problem is that the
OnCurrent event in Sub1 runs BEFORE Sub2 has loaded, so the first time
it causes an "Invalid reference to the property Form" error. I trap
for the error, then Sub2 loads, and everything works from this point.

CAUSE: subforms are controls, and they run their events before the
Main forms events. So the sequence of events when I open the Main form
is
Sub1: Open, Load, Activate, Current
Sub2: Open, Load, Activate, Current
Main: Open, Load, Activate, Current
The problem occurs in some forms and not others because of the order I
originally placed the subforms on them!

SOLUTION: Sub2 needs to load before Sub1, so that the code in the Sub1
OnCurrent event can reference it. Unfortunately, there is no load
sequence property for subforms, and the Tab Order property doesn't
affect the sequence of loading. However, you can influence the load
order!
1) remove the subforms from Main and save it. For good measure I also
did a compact and repair
2) add Sub2 to Main and Save it. Being paranoid, I did another compact
and repair
3) add Sub1 to Main and Save it. Now it works and I can get rid of the
error trapping!

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4614
by: Brian Morris | last post by:
I'm new to .NET and just trying a few things out, like emailing. I created a form in Visual Studio .Net to input some information for generating an email and I'm getting the following error when it executes both on my server or on the server of the .NET service provider. I'm obviously missing something very basic and I'm hoping one of you can point out my error. Thank you for your assistance. Brian
2
1588
by: Good Enchiladas | last post by:
While building on a class library for an object model, I get the above error message. The steps to recreate the problem are as follows: 1. Build a RootLevel.dll containing only this code: Public Class Root End Class
6
13594
by: TS | last post by:
Hi, i have a problem validating xml against schema. I used http://apps.gotdotnet.com/xmltools/xsdvalidator/Default.aspx validator and it says it is fine. Can you tell me why this doesn't work? Thanks! Schema: <?xml version="1.0"?> <xs:schema id="ReportInfo" targetNamespace="http://tempuri.org/Reports.xsd"
0
1007
by: John Hunter | last post by:
I've recently had a nasty problem with the "Invalid reference to the property Form" error in subforms - nasty because it doesn't seem to consistently happen to all forms which contain the same structure and code. Judging by the forums I've researched, it's not an uncommon error. I'm happy to say I've found a simple solution. OVERVIEW: I have a main form (no record source) which contains two subforms. The subforms are not linked, but...
7
17879
by: Dica | last post by:
i've used the sample code from msdn to create an encyption/decryption assembly as found here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT10.asp i'm able to encrypt and then decrypt data okay as in the following code: // encrypt the data // Encryptor enc = new Encryptor(EncryptionAlgorithm.TripleDes); byte key = Encoding.ASCII.GetBytes("0123456789012345");
5
2764
by: Mark Ingram | last post by:
Hi, ive written a custom control and i would like to display the "invalid property value" dialog box for certain properties on my form if the user enters a value outside the allowed range (in the visual studio designer). e.g. If i had a percentage property, i would want the user only to be able to enter Int32 values between 0&100. How can i do this?
2
7917
by: Dabbler | last post by:
In my Registrant FormView I have a DropDownList which loads data from a secondary SqlDataSource "sdsOfficeParks". I need the user to select an office park but save the selected value in the FormView's ObjectDataSource "odsRegistrant" . The following solution can't work because I need the ddl selected value bound to my odsRegistrant but both tables have the same column name for primary key. <asp:DropDownList ID="ddlOfficePark"...
1
8031
by: Java Guy | last post by:
I'm trying to view a web page. IE tells me there are (Java?) errors on the page. Here they are: Line: 15 Char: 7 Error: Wrong number of arguments or invalid propert assignment Code: 0 URL: http://(address.of.my.webcam):port/LiveView.html and
6
2433
by: KiwiGenie | last post by:
Hi..I am trying to make a search form. I am fairly new to access and could well be looking at it completely wrong. I have an unbound form with textboxes in the header for entering different search criteria. I have a subform for displaying the results, which is bound to Query4. SQL for Query4 (taken from sql view in query): SELECT tblRecipes.RecipeName, tblRecipes.FoodCategory, Sum(Query3.IngredCost) AS SumOfIngredCost, Query3.RecipeID FROM...
0
10148
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10002
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9938
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8822
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3528
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2794
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.