473,748 Members | 10,539 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Any way to determine the correct order of loading dependent subforms?

176 New Member
Hi everyone.

I have a few subforms in the main form that are dependent on each other with their data (not with child/master fields). Sometimes I get an invalid reference error because the referenced subform isn't loaded (yet). To make them load in the correct order I need to delete them all, then insert them one by one in a correct order. If, later on, I decide to edit one of them of or send it to background, the order breaks and once again do I get the error.

I've tried to determine the correct loading order with this code on the main form On Load event but to no avail:
Expand|Select|Wrap|Line Numbers
  1. Forms!frmMain!sfrmForm1.Form.RecordSource = "RecordSource1"
  2. DoEvents
  3. Forms!frmMain!sfrmForm2.Form.RecordSource = "RecordSource2"
  4. DoEvents
  5.  
(getting an error that the following action can't be done because it can't find the subform.)

Does anyone know what can be done?
Thanks a lot,
Michael.
Oct 22 '08 #1
8 1916
FishVal
2,653 Recognized Expert Specialist
Hello, Michael.

Though I've not tested it thoroughly but it most like form components are loaded when Form_Load event fires (I guess you don't have subforms in main form being in datasheet view, this case subforms are being loaded on demand). Why not to move your code to the event handler?

Regards,
Fish
Oct 22 '08 #2
Michael R
176 New Member
Hello, Michael.

Though I've not tested it thoroughly but it most like form components are loaded when Form_Load event fires (I guess you don't have subforms in main form being in datasheet view, this case subforms are being loaded on demand). Why not to move your code to the event handler?

Regards,
Fish
Most of my between-subforms code is event-oriented (for ex: changing a certain control in one from through AfterUpdate event changes records absolute position in another form from the On_Current event)

What do you mean by moving the code to the event handler?
Oct 22 '08 #3
FishVal
2,653 Recognized Expert Specialist
Most of my between-subforms code is event-oriented (for ex: changing a certain control in one from through AfterUpdate event changes records absolute position in another form from the On_Current event)

What do you mean by moving the code to the event handler?
I've assumed your code is run outside frmMain from module as soon as you reference it through Forms collection.
So, when the code you've posted is invoked and where does it reside?
Oct 22 '08 #4
Michael R
176 New Member
I've assumed your code is run outside frmMain from module as soon as you reference it through Forms collection.
So, when the code you've posted is invoked and where does it reside?
It is invoked from 1st subform's on current event using data (and variables) from 2nd subform.
Oct 22 '08 #5
Michael R
176 New Member
It is invoked from 1st subform's on current event using data (and variables) from 2nd subform.
Can I give any more details about this situation for the explanation to be clearer?
Oct 22 '08 #6
missinglinq
3,532 Recognized Expert Specialist
This is giving me a headache trying to follow, but there's one thing I think needs to be kept in mind, and it explains why the OPs original approach didn't work. In a form/subform setup, this is the order of event execution

Subform Form_Open
Subform Form_Load
Main Form Form_Open
Main Form Form_Load

I think the RecordSource of the subforms need to be set to nothing until the Main form's Form_Load fires. At this point you can assign the RecordSource for each subform, in whatever order you need.

Linq ;0)>
Oct 22 '08 #7
Michael R
176 New Member
I think the RecordSource of the subforms need to be set to nothing until the Main form's Form_Load fires. At this point you can assign the RecordSource for each subform, in whatever order you need.

Linq ;0)>
A good idea. I haven't tried it yet but I don't see why it should not work.
Thanks!
Oct 23 '08 #8
NeoPa
32,571 Recognized Expert Moderator MVP
It also explains why your code in the original post didn't fix the problem. That code essentially runs AFTER the problem had already occurred. You have to stop the automatic attempt to load the recordsets. Designing them as without record sources (as Linq suggests) should resolve that for you.
Oct 23 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2479
by: Manuel Kampert | last post by:
Hi, while playing around as an hobby programmer for the last decade I have now decided to dive deeper into the object oriented design and programming paradigm. To learn more about the OO story I have decided to write a small network management system. I have created the following (simplified) object model:
18
2887
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code that applies to all these events, but I need to have specific code execute when the form closes. The properties for this method are sender (the originator) and e (event arguments). I know how to get typeof (sender) to determine what form or...
5
2526
by: pooh | last post by:
I have a situation where the order of my cpp files in my g++ compile command line affects the program. Here is a simplified example: g++ -Wall -o test a.cpp b.cpp compiles, links and runs fine. g++ -Wall -o test b.cpp a.cpp
1
5411
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...
1
1637
by: sasan3 | last post by:
I have a main form "topform" contaning "subform1" and "subform2" The goal is: I need to requery subform2 on CURRENT event of subform1, and I need to load subform2 contents based on settings on subform1. The problem is: Order of loading is: subform1 subform2
4
1931
by: Bill Stock | last post by:
The few times in the past that I've loaded unbound data, I've tended to cheat and use temp tables (not really unbound) or use code for small datasets. I'm currently involved in a project that has numerous tables in the 200 column range, with several thousand rows of data. A consulting review prior to my involvement stressed the wasted space and database speed as the major impetus for normalization. Although the db actually works fairly...
0
1603
by: Ashok Mistry | last post by:
Hi all, I have a problem in loading Assembly dynamically through the Reflection. I want to Load an assembly, say, Main.dll. The Main.dll is dependent on a DLL, say Abc.dll, which is placed in another known directory. \AppRoot\Main.dll \AppRoot\AGroupOfDLLs\Abc.dll
1
1743
by: Ecohouse | last post by:
I have a main form with two subforms. The second subform has a combo box whose recordsource is set based on a field in the first subform. I tried putting some code in the first subform to do this. This is the code in the Form Current section: strSQL = "SELECT * FROM ModuleComponents WHERE TrainingModuleTopicSK = " & subTrainingModule.Form!TrainingModuleTopicSK & ";"
2
1853
by: wzhao2000 | last post by:
Back in COM time, it's possible to use #import statement in cpp to load COM object type info and use it at coding time. When the application is started, the underlying COM DLL will not be loaded until that part of code is called. Is there a similar thing in .Net (C#) application ? When I create C# application, I need to add reference to another assembly if I want to use its classes (I don't want to use reflection here). But this will...
0
8991
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
8831
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9548
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
9374
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
9325
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
9249
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
6076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4876
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2787
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.