473,289 Members | 1,808 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

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

176 100+
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 1892
FishVal
2,653 Expert 2GB
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 100+
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 Expert 2GB
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 100+
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 100+
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 Expert 2GB
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 100+
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,554 Expert Mod 16PB
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
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...
18
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...
5
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...
1
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...
1
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...
4
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...
0
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...
1
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...
2
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...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

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.