ControlSource Property Woes

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

    ControlSource Property Woes

    Good day,

    I have:

    1) A table with numbered fields (1, 2, 3, etc.)

    2) A form text box, whose ControlSource property contains an
    expression. This expression returns a number.

    If I just put a number in the ControlSource property, the text box
    would display the appropriate contents of the field in my table.
    However, because I have an expression returning a number, the text box
    displays the number. How can I get the ControlSource property to
    recognize the number as a field name and get the appropriate value for
    me?

    Thank you!
    Shelli Carol
    Scottsdale, Arizona
  • Shelli Carol

    #2
    Re: ControlSource Property Woes

    The number is returned by an expression. If I put the expression in
    brackets, I get a ?Name error on my form. I can't put the number in
    brackets because it only exists after the form is created using the
    expression.

    "Allen Browne" <abrowne1_SpamT rap@bigpond.net .au> wrote in message news:<PkY4b.779 22$bo1.46669@ne ws-server.bigpond. net.au>...[color=blue]
    > Enclose the number in square brackets.
    >
    > --
    > Allen Browne - Microsoft MVP. Perth, Western Australia.
    > Tips for Access users - http://allenbrowne.com/tips.html
    >
    > "Shelli Carol" <star_sphere@ya hoo.com> wrote in message
    > news:736cb06d.0 309012302.66e2e 999@posting.goo gle.com...[color=green]
    > > Good day,
    > >
    > > I have:
    > >
    > > 1) A table with numbered fields (1, 2, 3, etc.)
    > >
    > > 2) A form text box, whose ControlSource property contains an
    > > expression. This expression returns a number.
    > >
    > > If I just put a number in the ControlSource property, the text box
    > > would display the appropriate contents of the field in my table.
    > > However, because I have an expression returning a number, the text box
    > > displays the number. How can I get the ControlSource property to
    > > recognize the number as a field name and get the appropriate value for
    > > me?
    > >
    > > Thank you!
    > > Shelli Carol
    > > Scottsdale, Arizona[/color][/color]

    Comment

    • Shelli Carol

      #3
      Re: ControlSource Property Woes

      Hi Allen,

      Yes, I have a table with the first field named "1", the next named
      "2", etc.

      As I said before, I have an expression, namely a DLookup, pulling the
      numbers from somewhere else. When I put this: [DLookup(argumen ts)]
      in the ControlSource property, I only get a #Name? error in the text
      box.

      Thanks,
      Shelli

      "Allen Browne" <abrowne1_SpamT rap@bigpond.net .au> wrote in message news:<KQa5b.793 19$bo1.62667@ne ws-server.bigpond. net.au>...[color=blue]
      > Shelli, you say you have a table with numbered fields.
      > Does this mean the first field is named "1", and the next field is named
      > "2"?
      >
      > If so, you can refer to them in the ControlSource of a text box like this:
      > =[1] + [2]
      >
      > --
      > Allen Browne - Microsoft MVP. Perth, Western Australia.
      > Tips for Access users - http://allenbrowne.com/tips.html
      >
      > "Shelli Carol" <star_sphere@ya hoo.com> wrote in message
      > news:736cb06d.0 309021249.7cfe5 93b@posting.goo gle.com...[color=green]
      > > The number is returned by an expression. If I put the expression in
      > > brackets, I get a ?Name error on my form. I can't put the number in
      > > brackets because it only exists after the form is created using the
      > > expression.
      > >
      > > "Allen Browne" <abrowne1_SpamT rap@bigpond.net .au> wrote in message[/color]
      > news:<PkY4b.779 22$bo1.46669@ne ws-server.bigpond. net.au>...[color=green][color=darkred]
      > > > Enclose the number in square brackets.
      > > >
      > > > --
      > > > Allen Browne - Microsoft MVP. Perth, Western Australia.
      > > > Tips for Access users - http://allenbrowne.com/tips.html
      > > >
      > > > "Shelli Carol" <star_sphere@ya hoo.com> wrote in message
      > > > news:736cb06d.0 309012302.66e2e 999@posting.goo gle.com...
      > > > > Good day,
      > > > >
      > > > > I have:
      > > > >
      > > > > 1) A table with numbered fields (1, 2, 3, etc.)
      > > > >
      > > > > 2) A form text box, whose ControlSource property contains an
      > > > > expression. This expression returns a number.
      > > > >
      > > > > If I just put a number in the ControlSource property, the text box
      > > > > would display the appropriate contents of the field in my table.
      > > > > However, because I have an expression returning a number, the text box
      > > > > displays the number. How can I get the ControlSource property to
      > > > > recognize the number as a field name and get the appropriate value for
      > > > > me?
      > > > >
      > > > > Thank you!
      > > > > Shelli Carol
      > > > > Scottsdale, Arizona[/color][/color][/color]

      Comment

      • Allen Browne

        #4
        Re: ControlSource Property Woes

        To lookup the value of the field named "2", where the field named "1"
        contains "SomeValue
        =DLookup("[2]", "MyTable", "[1] = 'SomeValue'")

        The square brackets are crucial. If "1" is a Number field, lose the extra
        quotes, i.e.:
        =DLookup("[2]", "MyTable", "[1] = 9876")

        If the value is in another text box, you need to concatenate the value into
        the 3rd argument, i.e.:
        =DLookup("[2]", "MyTable", "[1] = " & [MyTextBox])
        or for a text field:
        =DLookup("[2]", "MyTable", "[1] = """ & [MyTextBox] & """")

        You may like to use the Immediate Window to test this and get it right.
        Press Ctrl+G, and enter:
        ? DLookup("[2]", "MyTable", "[1] = 'SomeValue'")

        --
        Allen Browne - Microsoft MVP. Perth, Western Australia.
        Tips for Access users - http://allenbrowne.com/tips.html

        "Shelli Carol" <star_sphere@ya hoo.com> wrote in message
        news:736cb06d.0 309022356.828cf f6@posting.goog le.com...[color=blue]
        > Hi Allen,
        >
        > Yes, I have a table with the first field named "1", the next named
        > "2", etc.
        >
        > As I said before, I have an expression, namely a DLookup, pulling the
        > numbers from somewhere else. When I put this: [DLookup(argumen ts)]
        > in the ControlSource property, I only get a #Name? error in the text
        > box.
        >
        > Thanks,
        > Shelli
        >
        > "Allen Browne" <abrowne1_SpamT rap@bigpond.net .au> wrote in message[/color]
        news:<KQa5b.793 19$bo1.62667@ne ws-server.bigpond. net.au>...[color=blue][color=green]
        > > Shelli, you say you have a table with numbered fields.
        > > Does this mean the first field is named "1", and the next field is named
        > > "2"?
        > >
        > > If so, you can refer to them in the ControlSource of a text box like[/color][/color]
        this:[color=blue][color=green]
        > > =[1] + [2]
        > >
        > > --
        > > Allen Browne - Microsoft MVP. Perth, Western Australia.
        > > Tips for Access users - http://allenbrowne.com/tips.html
        > >
        > > "Shelli Carol" <star_sphere@ya hoo.com> wrote in message
        > > news:736cb06d.0 309021249.7cfe5 93b@posting.goo gle.com...[color=darkred]
        > > > The number is returned by an expression. If I put the expression in
        > > > brackets, I get a ?Name error on my form. I can't put the number in
        > > > brackets because it only exists after the form is created using the
        > > > expression.
        > > >
        > > > "Allen Browne" <abrowne1_SpamT rap@bigpond.net .au> wrote in message[/color]
        > > news:<PkY4b.779 22$bo1.46669@ne ws-server.bigpond. net.au>...[color=darkred]
        > > > > Enclose the number in square brackets.
        > > > >
        > > > > --
        > > > > Allen Browne - Microsoft MVP. Perth, Western Australia.
        > > > > Tips for Access users - http://allenbrowne.com/tips.html
        > > > >
        > > > > "Shelli Carol" <star_sphere@ya hoo.com> wrote in message
        > > > > news:736cb06d.0 309012302.66e2e 999@posting.goo gle.com...
        > > > > > Good day,
        > > > > >
        > > > > > I have:
        > > > > >
        > > > > > 1) A table with numbered fields (1, 2, 3, etc.)
        > > > > >
        > > > > > 2) A form text box, whose ControlSource property contains an
        > > > > > expression. This expression returns a number.
        > > > > >
        > > > > > If I just put a number in the ControlSource property, the text box
        > > > > > would display the appropriate contents of the field in my table.
        > > > > > However, because I have an expression returning a number, the text[/color][/color][/color]
        box[color=blue][color=green][color=darkred]
        > > > > > displays the number. How can I get the ControlSource property to
        > > > > > recognize the number as a field name and get the appropriate value[/color][/color][/color]
        for[color=blue][color=green][color=darkred]
        > > > > > me?
        > > > > >
        > > > > > Thank you!
        > > > > > Shelli Carol
        > > > > > Scottsdale, Arizona[/color][/color][/color]


        Comment

        Working...