By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,264 Members | 1,271 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,264 IT Pros & Developers. It's quick & easy.

can you change to source object on subforms in code

P: n/a
I have a form that is broken down into 24 sub forms.
these are all tied to one subform, they are filtered based on other
things.

But I need to change the sub forms source object based on a selection.
I was going to try this..

For Each doc In dbs.Containers("Forms").Documents
frmname = doc.Name

If frmname = "DM hx1Mon" Then

DoCmd.OpenForm frmname, acDesign, , , , acHidden
For Each ctl In Forms(frmname).Controls
If ctl.ControlType = acSubform Then

For Each prp In ctl.Properties
Debug.Print "Just looking "&
prp.Name
Next

end if
next
End If

I can't find out exactly what I need to change.

just need to change "subfrm_drub_visit_1mon"
to "subfrm_drub_visit_3mon"
something like this
any pointers would be greatly appreciated
Mar 5 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Mar 5, 10:41 am, sparks <jstal...@swbell.netwrote:
I have a form that is broken down into 24 sub forms.
these are all tied to one subform, they are filtered based on other
things.

But I need to change the sub forms source object based on a selection.
I was going to try this..

For Each doc In dbs.Containers("Forms").Documents
frmname = doc.Name

If frmname = "DM hx1Mon" Then

DoCmd.OpenForm frmname, acDesign, , , , acHidden
For Each ctl In Forms(frmname).Controls
If ctl.ControlType = acSubform Then

For Each prp In ctl.Properties
Debug.Print "Just looking "&
prp.Name
Next

end if
next
End If

I can't find out exactly what I need to change.

just need to change "subfrm_drub_visit_1mon"
to "subfrm_drub_visit_3mon"

something like this
any pointers would be greatly appreciated

The subform control contains the property you need to change.

Me!subFormControl.SourceObject="formName"

You may in some rare cases need to repaint the screen after changing
the object.
Me.Repaint

Mar 5 '07 #2

P: n/a
I went right past it..

THANKS BIG TIME for your help

(in my defense its monday) but isn't every day LOL
On 5 Mar 2007 08:00:28 -0800, "storrboy" <st******@sympatico.ca>
wrote:
>On Mar 5, 10:41 am, sparks <jstal...@swbell.netwrote:
>I have a form that is broken down into 24 sub forms.
these are all tied to one subform, they are filtered based on other
things.

But I need to change the sub forms source object based on a selection.
I was going to try this..

For Each doc In dbs.Containers("Forms").Documents
frmname = doc.Name

If frmname = "DM hx1Mon" Then

DoCmd.OpenForm frmname, acDesign, , , , acHidden
For Each ctl In Forms(frmname).Controls
If ctl.ControlType = acSubform Then

For Each prp In ctl.Properties
Debug.Print "Just looking "&
prp.Name
Next

end if
next
End If

I can't find out exactly what I need to change.

just need to change "subfrm_drub_visit_1mon"
to "subfrm_drub_visit_3mon"

something like this
any pointers would be greatly appreciated


The subform control contains the property you need to change.

Me!subFormControl.SourceObject="formName"

You may in some rare cases need to repaint the screen after changing
the object.
Me.Repaint
Mar 5 '07 #3

P: n/a
"sparks" <js******@swbell.netwrote in message
news:3s********************************@4ax.com...
>I went right past it..

THANKS BIG TIME for your help

(in my defense its monday) but isn't every day LOL
Just remember, you don't need, nor want to open the form in design
mode......

You can change this property at run time....
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
Mar 5 '07 #4

P: n/a
what I am doing is taking a form that was designed for 1 time data
entry and converting it to many visits.
so a form that would be Baseline with 24 subforms called Base
will be a new form 1MonthVisit with 24 subforms called 1Month.
So I did it in place and making new forms and subforms.
So I did it this way, kinda worried that if I did it at run time
using one form and 1 subform...someone would make it mess up and then
the records would be a mess.
(the people around here have a way of screwing up a crowbar taking it
out of the box)
Its a pain in the you know what.
filters out the arse.

almost finished I hope.

On Mon, 05 Mar 2007 16:25:12 GMT, "Albert D. Kallal"
<Pl*******************@msn.comwrote:
>"sparks" <js******@swbell.netwrote in message
news:3s********************************@4ax.com.. .
>>I went right past it..

THANKS BIG TIME for your help

(in my defense its monday) but isn't every day LOL

Just remember, you don't need, nor want to open the form in design
mode......

You can change this property at run time....
Mar 5 '07 #5

P: n/a
On Mar 5, 1:11 pm, sparks <jstal...@swbell.netwrote:
what I am doing is taking a form that was designed for 1 time data
entry and converting it to many visits.
so a form that would be Baseline with 24 subforms called Base
will be a new form 1MonthVisit with 24 subforms called 1Month.
So I did it in place and making new forms and subforms.
So I did it this way, kinda worried that if I did it at run time
using one form and 1 subform...someone would make it mess up and then
the records would be a mess.
(the people around here have a way of screwing up a crowbar taking it
out of the box)
Its a pain in the you know what.
filters out the arse.

almost finished I hope.

On Mon, 05 Mar 2007 16:25:12 GMT, "Albert D. Kallal"

<PleaseNOOOsPAMmkal...@msn.comwrote:
"sparks" <jstal...@swbell.netwrote in message
news:3s********************************@4ax.com...
>I went right past it..
THANKS BIG TIME for your help
(in my defense its monday) but isn't every day LOL
Just remember, you don't need, nor want to open the form in design
mode......
You can change this property at run time....

I would think having one form for each day and a master for each month
would be the most cumbersome thing to administer. There has to be a
better way to organize the data so that you can minimize the number of
forms. Before you implement (or even continue with) this I would
seriously spend some time reaserching similar applications and re-
thinking the schema.
But in the end it's up to you and what's best for your task.

Mar 5 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.