[AccessD] Change both subform sourceobject and recordsource

Bruce Bruen bbruen at bigpond.com
Tue May 27 05:20:54 CDT 2003


Thanks A.D that is what I needed!
 
Bruce
 
(Actually, what I need is a packet of "Obvious Pills"  :-)
 
 
Sent: Tuesday, May 27, 2003 7:10 PM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] Change both subform sourceobject and recordsource



Bruce,
 
    Let MySF be the name of SubForm control, "MyForm" the name of form
serving as source object for MySF and "MyQ" the name of saved query or
table serving as record source for "MyForm". You could try the following
code (from the parent form) -
 
    MySF.SourceObject = "MyForm"
    MySF.Form.RecordSource = "MyQ"
 
    This will effect the desired changes at run time.
 
Regards,
A.D.Tejpal
--------------

----- Original Message ----- 
From: Michael R Mattys <mailto:michael.mattys at adelphia.net>  
To: accessd at databaseadvisors.com 
Sent: Tuesday, May 27, 2003 08:44
Subject: Re: [AccessD] Change both subform sourceobject and recordsource

Hi Bruce,

Unless someone knows better ...
It looks like you'd have to open the source object
in design view (hidden) and set it's recordsource,
save it, and then open it in the main form.

Michael R. Mattys
www.mattysconsulting.com

----- Original Message ----- 
From: "Bruce Bruen" <bbruen at bigpond.com>
To: <accessd at databaseadvisors.com>
Sent: Monday, May 26, 2003 10:47 PM
Subject: [AccessD] Change both subform sourceobject and recordsource


> Dear List,
> 
> I have a form that contains a changeable subform.  That is, the source
> object of the subform is set on the fly by an option group button on
the
> main form. This works fine, the correct subform pops up as required.
> 
> Now I have a situation where one of the subforms (it's a generic list)
> could be re-used for different record sources.  That is sometimes it
> should list tblA, sometimes tblB, again dependent on which button the
> user clicks.  The record sources are completely different, I cant use
> filters.
> 
> My problem is how do I get the for to know which record source to use?
> Normally, I would use an openargs value to achieve this, but as I'm
> "opening" the form using a source object switch.
> 
> Some code may illustrate
> 
> Private Sub grpMain_Click()
>     Select Case Me.grpMain
>         Case 1: Me.subMain.SourceObject = "frmLoadLog"
>         Case 2: Me.subMain.SourceObject = "frmReviewLoad"
>         Case 3: Me.subMain.SourceObject = "frmActive1"
>         Case 4: Me.subMain.SourceObject = "frmActive1"
>         Case 9: DoCmd.Close
>     End Select
> End Sub
> 
> My problem is with case 4.  This is the subform I want to reuse.  
> My mind has gone completely blank on this (some would say "small
> change"). I just cannot see how I can send frmActive1 some sort of
> indicator to change its record source from tblA to tblB.
> 
> Any thoughts?
> 
> Bruce


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030527/2d68befd/attachment-0001.html>


More information about the AccessD mailing list