can you change to source object on subforms in code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sparks

    can you change to source object on subforms in code

    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").Docume nts
    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_vi sit_1mon"
    to "subfrm_drub_vi sit_3mon"


    something like this
    any pointers would be greatly appreciated
  • storrboy

    #2
    Re: can you change to source object on subforms in code

    On Mar 5, 10:41 am, sparks <jstal...@swbel l.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").Docume nts
    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_vi sit_1mon"
    to "subfrm_drub_vi sit_3mon"
    >
    something like this
    any pointers would be greatly appreciated

    The subform control contains the property you need to change.

    Me!subFormContr ol.SourceObject ="formName"

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

    Comment

    • sparks

      #3
      Re: can you change to source object on subforms in code

      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" <storrboy@sympa tico.ca>
      wrote:
      >On Mar 5, 10:41 am, sparks <jstal...@swbel l.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").Docume nts
      > 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_vi sit_1mon"
      >to "subfrm_drub_vi sit_3mon"
      >>
      >something like this
      >any pointers would be greatly appreciated
      >
      >
      >The subform control contains the property you need to change.
      >
      >Me!subFormCont rol.SourceObjec t="formName"
      >
      >You may in some rare cases need to repaint the screen after changing
      >the object.
      >Me.Repaint

      Comment

      • Albert D. Kallal

        #4
        Re: can you change to source object on subforms in code

        "sparks" <jstalnak@swbel l.netwrote in message
        news:3sgou2dttv irm03gta0l6jhcl qf6pbab88@4ax.c om...
        >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
        pleaseNOOSpamKa llal@msn.com


        Comment

        • sparks

          #5
          Re: can you change to source object on subforms in code

          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...someo ne 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"
          <PleaseNOOOsPAM mkallal@msn.com wrote:
          >"sparks" <jstalnak@swbel l.netwrote in message
          >news:3sgou2dtt virm03gta0l6jhc lqf6pbab88@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....

          Comment

          • storrboy

            #6
            Re: can you change to source object on subforms in code

            On Mar 5, 1:11 pm, sparks <jstal...@swbel l.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...someo ne 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"
            >
            <PleaseNOOOsPAM mkal...@msn.com wrote:
            "sparks" <jstal...@swbel l.netwrote in message
            news:3sgou2dttv irm03gta0l6jhcl qf6pbab88@4ax.c om...
            >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.

            Comment

            Working...