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

ControlSource Property Woes

P: n/a
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
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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" <ab***************@bigpond.net.au> wrote in message news:<Pk*******************@news-server.bigpond.net.au>...
Enclose the number in square brackets.

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

"Shelli Carol" <st*********@yahoo.com> wrote in message
news:73**************************@posting.google.c om...
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

Nov 12 '05 #2

P: n/a
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(arguments)]
in the ControlSource property, I only get a #Name? error in the text
box.

Thanks,
Shelli

"Allen Browne" <ab***************@bigpond.net.au> wrote in message news:<KQ*******************@news-server.bigpond.net.au>...
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" <st*********@yahoo.com> wrote in message
news:73**************************@posting.google.c om...
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" <ab***************@bigpond.net.au> wrote in message

news:<Pk*******************@news-server.bigpond.net.au>...
Enclose the number in square brackets.

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

"Shelli Carol" <st*********@yahoo.com> wrote in message
news:73**************************@posting.google.c om...
> 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

Nov 12 '05 #3

P: n/a
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" <st*********@yahoo.com> wrote in message
news:73*************************@posting.google.co m...
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(arguments)]
in the ControlSource property, I only get a #Name? error in the text
box.

Thanks,
Shelli

"Allen Browne" <ab***************@bigpond.net.au> wrote in message

news:<KQ*******************@news-server.bigpond.net.au>...
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" <st*********@yahoo.com> wrote in message
news:73**************************@posting.google.c om...
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" <ab***************@bigpond.net.au> wrote in message

news:<Pk*******************@news-server.bigpond.net.au>...
> Enclose the number in square brackets.
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia.
> Tips for Access users - http://allenbrowne.com/tips.html
>
> "Shelli Carol" <st*********@yahoo.com> wrote in message
> news:73**************************@posting.google.c om...
> > 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

Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.