Connecting Tech Pros Worldwide Help | Site Map

Loading Subforms Problem

  #1  
Old December 12th, 2006, 04:25 PM
Ecohouse
Guest
 
Posts: n/a
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 & ";"


submodulecomponents.Form!cboModuleComponentTopicsS K.RowSource = strSQL

This wasn't working because the subforms load before the main form.
So I went to the main form and for each subform I removed the
Sourceobject. Then I set the sourceobjects for the subforms through
code. This is the code in Form Load:

With Me
..subTrainingModule.SourceObject = "subTrainingModule"
..subModuleComponents.SourceObject = "subModuleComponents"
End With

I don't get an error message now but the subforms come up empty. So
now I'm stuck. Does anybody have any ideas where I'm going wrong with
this?

Thanks in advance for the help.

  #2  
Old December 14th, 2006, 10:29 PM
CDMAPoster@FortuneJames.com
Guest
 
Posts: n/a

re: Loading Subforms Problem



Ecohouse wrote:
Quote:
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 & ";"
>
>
submodulecomponents.Form!cboModuleComponentTopicsS K.RowSource = strSQL
>
This wasn't working because the subforms load before the main form.
So I went to the main form and for each subform I removed the
Sourceobject. Then I set the sourceobjects for the subforms through
code. This is the code in Form Load:
>
With Me
.subTrainingModule.SourceObject = "subTrainingModule"
.subModuleComponents.SourceObject = "subModuleComponents"
End With
>
I don't get an error message now but the subforms come up empty. So
now I'm stuck. Does anybody have any ideas where I'm going wrong with
this?
>
Thanks in advance for the help.
Here's a way I do dynamic source objects:

NameOfSubformControl.SourceObject = NameOfSumForm

E.g.,

SubformIDO.SourceObject = "frmSubIDO"
SubformIDO.Form.RecordSource = "SELECT IDOID, ... FROM tblIDO;"
DoEvents

I believe that simply setting the SourceObject will cause the
recordsource to requery. In cases where the recordsource will be
changing I remove the recordsource from the subform.

When two subforms are involved I use the following:

http://groups.google.com/group/comp....6ad010d?hl=en&

I haven't thought much about the best way to do that.

James A. Fortune
CDMAPoster@FortuneJames.com

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linking Multiple Subforms Ecohouse answers 9 December 17th, 2006 08:45 PM
circular dependency between subforms, problem cased by subform loading order sasan3@gmail.com answers 1 November 13th, 2005 03:01 PM
Access 2003 Crash JK Peck answers 14 November 13th, 2005 04:46 AM
OnActivation events and subforms in main form. Olivier answers 0 November 12th, 2005 04:34 PM