change form property using SetValue

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

    #1

    change form property using SetValue

    Hey,

    I am using SetValue to change the DataEntry property of a form to
    "YES". But It doesn't work. No error messages, but the property didn't
    change.Followin g is the what I am writing
    SetValue:
    Item: [Forms]![SubHistory]![Form].DataEntry
    Expression:Yes

    Does anyone know what is wrong? Thanks.

    Mindy

  • Allen Browne

    #2
    Re: change form property using SetValue

    Is SubHistory a subform?

    If so, you will need to get at it through the main form, e.g.:
    Forms!YourMainF orm!SubHistory. Form.DataEntry

    If not, drop the .Form bit:
    Forms!SubHistor y.DataEntry

    If the record is dirty, you may need to save the record first.

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "Mindy" <master2005_sas @yahoo.com> wrote in message
    news:1133828291 .294398.210960@ o13g2000cwo.goo glegroups.com.. .[color=blue]
    >
    > I am using SetValue to change the DataEntry property of a form to
    > "YES". But It doesn't work. No error messages, but the property didn't
    > change.Followin g is the what I am writing
    > SetValue:
    > Item: [Forms]![SubHistory]![Form].DataEntry
    > Expression:Yes
    >
    > Does anyone know what is wrong? Thanks.
    >
    > Mindy[/color]


    Comment

    • Mindy

      #3
      Re: change form property using SetValue

      Allen,

      SubHistory is a subform and I try the one you suggested for subform,
      and here is the error message I get when I run forms:

      The object you referenced in the visual basic procedure as an OLE
      object isn't an OLE object.

      Do you have any idea of this? Thanks.

      Mindy

      Allen Browne wrote:[color=blue]
      > Is SubHistory a subform?
      >
      > If so, you will need to get at it through the main form, e.g.:
      > Forms!YourMainF orm!SubHistory. Form.DataEntry
      >
      > If not, drop the .Form bit:
      > Forms!SubHistor y.DataEntry
      >
      > If the record is dirty, you may need to save the record first.
      >
      > --
      > Allen Browne - Microsoft MVP. Perth, Western Australia.
      > Tips for Access users - http://allenbrowne.com/tips.html
      > Reply to group, rather than allenbrowne at mvps dot org.
      >
      > "Mindy" <master2005_sas @yahoo.com> wrote in message
      > news:1133828291 .294398.210960@ o13g2000cwo.goo glegroups.com.. .[color=green]
      > >
      > > I am using SetValue to change the DataEntry property of a form to
      > > "YES". But It doesn't work. No error messages, but the property didn't
      > > change.Followin g is the what I am writing
      > > SetValue:
      > > Item: [Forms]![SubHistory]![Form].DataEntry
      > > Expression:Yes
      > >
      > > Does anyone know what is wrong? Thanks.
      > >
      > > Mindy[/color][/color]

      Comment

      • Allen Browne

        #4
        Re: change form property using SetValue

        The message suggests that something has the wrong name.

        You might open the main form in design view, right-click the subform, and
        choose Properties? What is in its Name property? The Name of the subform
        control may not be the same as the name of the form that is loaded into the
        control (its SourceObject.)

        What confuses me, though, is that you said you were using SetValue, so I
        assume you are using a macro. Yet the error message refers to a visual basic
        procedure. You may well have more than one problem here.

        --
        Allen Browne - Microsoft MVP. Perth, Western Australia.
        Tips for Access users - http://allenbrowne.com/tips.html
        Reply to group, rather than allenbrowne at mvps dot org.

        "Mindy" <master2005_sas @yahoo.com> wrote in message
        news:1133890234 .331670.180560@ o13g2000cwo.goo glegroups.com.. .[color=blue]
        > Allen,
        >
        > SubHistory is a subform and I try the one you suggested for subform,
        > and here is the error message I get when I run forms:
        >
        > The object you referenced in the visual basic procedure as an OLE
        > object isn't an OLE object.
        >
        > Do you have any idea of this? Thanks.
        >
        > Mindy
        >
        > Allen Browne wrote:[color=green]
        >> Is SubHistory a subform?
        >>
        >> If so, you will need to get at it through the main form, e.g.:
        >> Forms!YourMainF orm!SubHistory. Form.DataEntry
        >>
        >> If not, drop the .Form bit:
        >> Forms!SubHistor y.DataEntry
        >>
        >> If the record is dirty, you may need to save the record first.
        >>
        >> "Mindy" <master2005_sas @yahoo.com> wrote in message
        >> news:1133828291 .294398.210960@ o13g2000cwo.goo glegroups.com.. .[color=darkred]
        >> >
        >> > I am using SetValue to change the DataEntry property of a form to
        >> > "YES". But It doesn't work. No error messages, but the property didn't
        >> > change.Followin g is the what I am writing
        >> > SetValue:
        >> > Item: [Forms]![SubHistory]![Form].DataEntry
        >> > Expression:Yes
        >> >
        >> > Does anyone know what is wrong? Thanks.
        >> >
        >> > Mindy[/color][/color][/color]


        Comment

        • Mindy

          #5
          Re: change form property using SetValue

          Sorry, I didn't explain it clearly. The forms!formname! controlname of
          setvalue is for setting up value of a control. What I want here is
          different.

          when we chose a form property, we will see form/data/event/other/all,
          and under "data" there is Record Source, Filter, ..., Allow Edit, ...,
          what I want is after a user hit one button, the "Allow Edit" property
          will be changed from "NO" to "YES."

          Thanks.

          Mindy

          Comment

          • Allen Browne

            #6
            Re: change form property using SetValue

            Okay, we are going to build this reference a step at a time.

            1. Make sure this form is open.

            2. Press Ctrl+G to open the Immediate window.

            3. Enter:
            ? Forms![YourMainForm].Name
            substituting the name of your main form in brackets.
            When you press Enter, Access should show the name.

            4. Once you have that working you can try to get the reference to the
            subform. On a fresh line in the Immediate window, try:
            ? Forms![YourMainForm]![SubHistory].Form.Name
            If that responds with SubHistory, the reference is correct.
            If not, then the subform control is named something different.

            5. Once that is working, try:
            ? Forms![YourMainForm]![SubHistory].Form.AllowEdit s
            Access should respond with either True or False.

            6. Once that is working, you can copy the expression (without the question
            mark), and paste it into your macro below the SetValue action.

            --
            Allen Browne - Microsoft MVP. Perth, Western Australia.
            Tips for Access users - http://allenbrowne.com/tips.html
            Reply to group, rather than allenbrowne at mvps dot org.

            "Mindy" <master2005_sas @yahoo.com> wrote in message
            news:1133994884 .286349.314600@ g49g2000cwa.goo glegroups.com.. .[color=blue]
            > Sorry, I didn't explain it clearly. The forms!formname! controlname of
            > setvalue is for setting up value of a control. What I want here is
            > different.
            >
            > when we chose a form property, we will see form/data/event/other/all,
            > and under "data" there is Record Source, Filter, ..., Allow Edit, ...,
            > what I want is after a user hit one button, the "Allow Edit" property
            > will be changed from "NO" to "YES."
            >
            > Thanks.
            >
            > Mindy[/color]


            Comment

            • Mindy

              #7
              Re: change form property using SetValue

              Thanks a lot. It's very helpful. And it works now. Mindy
              Allen Browne wrote:[color=blue]
              > Okay, we are going to build this reference a step at a time.
              >
              > 1. Make sure this form is open.
              >
              > 2. Press Ctrl+G to open the Immediate window.
              >
              > 3. Enter:
              > ? Forms![YourMainForm].Name
              > substituting the name of your main form in brackets.
              > When you press Enter, Access should show the name.
              >
              > 4. Once you have that working you can try to get the reference to the
              > subform. On a fresh line in the Immediate window, try:
              > ? Forms![YourMainForm]![SubHistory].Form.Name
              > If that responds with SubHistory, the reference is correct.
              > If not, then the subform control is named something different.
              >
              > 5. Once that is working, try:
              > ? Forms![YourMainForm]![SubHistory].Form.AllowEdit s
              > Access should respond with either True or False.
              >
              > 6. Once that is working, you can copy the expression (without the question
              > mark), and paste it into your macro below the SetValue action.
              >
              > --
              > Allen Browne - Microsoft MVP. Perth, Western Australia.
              > Tips for Access users - http://allenbrowne.com/tips.html
              > Reply to group, rather than allenbrowne at mvps dot org.
              >
              > "Mindy" <master2005_sas @yahoo.com> wrote in message
              > news:1133994884 .286349.314600@ g49g2000cwa.goo glegroups.com.. .[color=green]
              > > Sorry, I didn't explain it clearly. The forms!formname! controlname of
              > > setvalue is for setting up value of a control. What I want here is
              > > different.
              > >
              > > when we chose a form property, we will see form/data/event/other/all,
              > > and under "data" there is Record Source, Filter, ..., Allow Edit, ...,
              > > what I want is after a user hit one button, the "Allow Edit" property
              > > will be changed from "NO" to "YES."
              > >
              > > Thanks.
              > >
              > > Mindy[/color][/color]

              Comment

              Working...