473,757 Members | 9,463 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 5411
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
9489
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10072
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
9906
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...
0
9737
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8737
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...
0
5172
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3829
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
3
3399
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.