Text Box Control Source

G

Guest

I have a text box that I want to report a certain field for most records in a
query, but when it gets to certain records it needs to report another field.
Therefore I have put an IIF statement into the textbox. It produces "#error".
While troubleshooting it I realized that the second I put the field into a
formula it produces an error, even if there's not really any calculation.

What I mean is, if I put this:

FIELDNAME

in the control source it works fine. If I put this:

=[FIELDNAME]

in the control source it immediately produces an error.

I think I'm overlooking something pretty simple here, but it's got me stumped.

Thanks,
Graham
 
F

fredg

I have a text box that I want to report a certain field for most records in a
query, but when it gets to certain records it needs to report another field.
Therefore I have put an IIF statement into the textbox. It produces "#error".
While troubleshooting it I realized that the second I put the field into a
formula it produces an error, even if there's not really any calculation.

What I mean is, if I put this:

FIELDNAME

in the control source it works fine. If I put this:

=[FIELDNAME]

in the control source it immediately produces an error.

I think I'm overlooking something pretty simple here, but it's got me stumped.

Thanks,
Graham

When the control source of a control is an expression (i.e.
=[FieldName]), the name of that control cannot be the same as the name
of a field used in the expression.
Just change the name of the control.
 
G

Guest

Thanks for the speedy reply fredg. I found this piece of advice elsewhere on
the form before I posted, but when I read it the first time I didn't quite
clue in to the problem. The name of my controls displaying the query results
are just the defaults, like Text12 for example. I tried changing this anyways
and of course it made no difference.

When I read your reply I thought of what the problem is. I have Labels at
the top of my form that are named the same as the fields from the query. I
didn't realize that the name of the field from the query couldn't be the same
as the name of ANY control on the form. Whoops! All good now, thanks for your
help.

Graham

fredg said:
I have a text box that I want to report a certain field for most records in a
query, but when it gets to certain records it needs to report another field.
Therefore I have put an IIF statement into the textbox. It produces "#error".
While troubleshooting it I realized that the second I put the field into a
formula it produces an error, even if there's not really any calculation.

What I mean is, if I put this:

FIELDNAME

in the control source it works fine. If I put this:

=[FIELDNAME]

in the control source it immediately produces an error.

I think I'm overlooking something pretty simple here, but it's got me stumped.

Thanks,
Graham

When the control source of a control is an expression (i.e.
=[FieldName]), the name of that control cannot be the same as the name
of a field used in the expression.
Just change the name of the control.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top