473,418 Members | 2,087 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,418 software developers and data experts.

circular dependency between subforms, problem cased by subform loading order



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
topform

When subform1 is loaded, CURRENT event happens, subform2 is not yet
loaded so my code to requery subform2 fails!

Questions:
1-What is a good strategy to handle such situations in general.
2-How do I handle this case specifically?
3-Is there a way to know if a subform is yet loaded or not?
Thanks.

Nov 13 '05 #1
1 1621
sa****@gmail.com wrote:
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
topform

When subform1 is loaded, CURRENT event happens, subform2 is not yet
loaded so my code to requery subform2 fails!

Questions:
1-What is a good strategy to handle such situations in general.
2-How do I handle this case specifically?
3-Is there a way to know if a subform is yet loaded or not?
Thanks.


Here's what I do:

'Code behind subform1

Private Sub Form_Current()
If Not IsNull(Me.IdIDO) Then
Call Form_frmIDOReconciliation.RequerySubform2(CStr(Me. IdIDO))
End If
End Sub

'Code behind the main form

Public Sub RequerySubform2(strIdIDO As String)
'Set visible = false and make visible to keep subform OnCurrent from
running
If SubformIDOReconciliation2.Visible = False Then
SubformIDOReconciliation2.Visible = True
Exit Sub
End If
SubformIDOReconciliation2.Form.RecordSource = "SELECT * FROM
tblIDOItems WHERE IdIDO = " & strIdIDO & " ORDER BY IdItem;"
SubformIDOReconciliation2.Form.Refresh
SubformIDOReconciliation2.Form.Repaint
End Sub

Starting the subform visible property false seems to keep its Current
event from running immediately after the form opens. I don't know what
will happen if the RecordSource is not set dynamically though. Perhaps
this will give you an idea. When an IDO is clicked on subform1's
datasheet the corresponding items show up in subform2's datasheet.
Subform2 doesn't show until an IDO line is clicked in subform1. I
really haven't thought much about the best strategy. I just used the
first idea that worked for me. I suppose this would be referred to as
'lazy optimization' or 'optimization on demand.' I also haven't
thought about how to determine if a subform is loaded or not. I assume
they get loaded when the form opens unless the SourceObject property of
the Subform control is used to load a different subform later.

James A. Fortune

Nov 13 '05 #2

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

Similar topics

1
by: Alan Bloom | last post by:
I'm designing a db which stores client details but each client has multiple 'occasions'. For each occasion there is a section which has items purchased (there are sometimes none, sometimes...
9
by: Zeeshan Iqbal via AccessMonster.com | last post by:
hi, im trying to design a form with two subforms. subforms no.1 (orders) is connected to the main form by customer ID and i dont know how i can connect another subform (order details)to the first...
12
by: Paul T. RONG | last post by:
Is it possible to divide a tall subform with 80 records to two subforms each with 40 records? Dear All, What I have: Tables: tblProduct, tblOrder, tblOrderDetail
0
by: cwm137 | last post by:
I have a form named "Customer Search" with a subform called "Cust Search Subform" that contains summary data about every order a customer has made. I would like to be able to select a single order...
7
by: barias | last post by:
Although circular dependencies are something developers should normally avoid, unfortunately they are very easy to create accidentally between classes in a VS project (i.e. circular compile-time...
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...
9
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform relates to the main form using an identity key (this works). The second subform relates to both the main and first subform. But I want to...
2
by: darnel | last post by:
I have 4 hierarchical tables and want to display it all together as a form and 3 subforms, when subform displays (and allow to add/edit) only relevant items from each superior subform. Tables are:...
8
by: Michael R | last post by:
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
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...

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.