473,287 Members | 1,663 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,287 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 1615
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
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:
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 =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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: 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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.