PC Review


Reply
Thread Tools Rate Thread

Text box formula

 
 
=?Utf-8?B?Y3RkYWs=?=
Guest
Posts: n/a
 
      18th Sep 2004
I have two reports with the same text box in each. The Control Source for
each is the same and is:
=Mid([Zipcode],1,5) & "-" & Mid([Zipcode],6,4)

This formula works in one report but gives "#Error" for the other.
Any ideas why?

ctdak

 
Reply With Quote
 
 
 
 
Ken Snell [MVP]
Guest
Posts: n/a
 
      19th Sep 2004
Is there a field or control named Zipcode in the report that doesn't work?

--

Ken Snell
<MS ACCESS MVP>

"ctdak" <(E-Mail Removed)> wrote in message
news:F8C95BBF-C107-4980-8834-(E-Mail Removed)...
> I have two reports with the same text box in each. The Control Source for
> each is the same and is:
> =Mid([Zipcode],1,5) & "-" & Mid([Zipcode],6,4)
>
> This formula works in one report but gives "#Error" for the other.
> Any ideas why?
>
> ctdak
>



 
Reply With Quote
 
 
 
 
Marshall Barton
Guest
Posts: n/a
 
      19th Sep 2004
ctdak wrote:

>I have two reports with the same text box in each. The Control Source for
>each is the same and is:
>=Mid([Zipcode],1,5) & "-" & Mid([Zipcode],6,4)
>
>This formula works in one report but gives "#Error" for the other.
>Any ideas why?


Make sure the text box is named something other than ZipCode
(e.g. txtZipCode).

--
Marsh
MVP [MS Access]
 
Reply With Quote
 
=?Utf-8?B?Y3RkYWs=?=
Guest
Posts: n/a
 
      19th Sep 2004
You were right. That was the problem! The text box was named the same as
the field name ZipCode. Strange that this should matter though. When you
add a control for a field, Access automatically makes the control name and
the control source equal the field name, so why does the control name have to
be different when you change the control source to a formula using the field
name?

ctdak


"Marshall Barton" wrote:

> ctdak wrote:
>
> >I have two reports with the same text box in each. The Control Source for
> >each is the same and is:
> >=Mid([Zipcode],1,5) & "-" & Mid([Zipcode],6,4)
> >
> >This formula works in one report but gives "#Error" for the other.
> >Any ideas why?

>
> Make sure the text box is named something other than ZipCode
> (e.g. txtZipCode).
>
> --
> Marsh
> MVP [MS Access]
>

 
Reply With Quote
 
Marshall Barton
Guest
Posts: n/a
 
      19th Sep 2004
ctdak wrote:

>You were right. That was the problem! The text box was named the same as
>the field name ZipCode. Strange that this should matter though. When you
>add a control for a field, Access automatically makes the control name and
>the control source equal the field name, so why does the control name have to
>be different when you change the control source to a formula using the field
>name?



If the control is just bound to a field, then you do not
use the = sign and Access "knows" that it should get the
field from that table/query and there is no ambiguity.

In expressions, the confusion arises because it can refer to
a field in the form's record source table/query or a control
on the form by just using its name anywhere. There is no
syntax to indicate which one you want to use. So, if you
have a control named ZipCode and it has an expression like
yours, then, Access thinks the expression's ZipCode is
referring to the control named ZipCode, which is an infinite
loop, thus the #Error.

As far as Access defaulting the control name to the field
name when you drag a field from the field list to the
form/report, you've just joined a very long list of people
with the same complaint. A lot of folks avoid this isuue by
developing the habit of prefixing their control names with
an abbreviation of the type of the control (e.g. txt, cbo,
etc) whenever they refer to a control in a control
expression or in VBA code.

--
Marsh
MVP [MS Access]
 
Reply With Quote
 
=?Utf-8?B?Y3RkYWs=?=
Guest
Posts: n/a
 
      21st Sep 2004
That makes sense. I never thought of that before - that Access can't
differentiate between a table/query field name and a form control name when
they are the same.
ctdak


"Marshall Barton" wrote:

> ctdak wrote:
>
> >You were right. That was the problem! The text box was named the same as
> >the field name ZipCode. Strange that this should matter though. When you
> >add a control for a field, Access automatically makes the control name and
> >the control source equal the field name, so why does the control name have to
> >be different when you change the control source to a formula using the field
> >name?

>
>
> If the control is just bound to a field, then you do not
> use the = sign and Access "knows" that it should get the
> field from that table/query and there is no ambiguity.
>
> In expressions, the confusion arises because it can refer to
> a field in the form's record source table/query or a control
> on the form by just using its name anywhere. There is no
> syntax to indicate which one you want to use. So, if you
> have a control named ZipCode and it has an expression like
> yours, then, Access thinks the expression's ZipCode is
> referring to the control named ZipCode, which is an infinite
> loop, thus the #Error.
>
> As far as Access defaulting the control name to the field
> name when you drag a field from the field list to the
> form/report, you've just joined a very long list of people
> with the same complaint. A lot of folks avoid this isuue by
> developing the habit of prefixing their control names with
> an abbreviation of the type of the control (e.g. txt, cbo,
> etc) whenever they refer to a control in a control
> expression or in VBA code.
>
> --
> Marsh
> MVP [MS Access]
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A new text box contains text from an existing text box. Solution? =?Utf-8?B?QWtodGFy?= Microsoft Word Document Management 1 2nd May 2007 06:11 PM
Display Qtrly data in form text box Formula in text box =?Utf-8?B?ZGVlZHM=?= Microsoft Access Forms 4 21st Mar 2007 08:41 PM
Copy text from Text box to text box =?Utf-8?B?U3RldmUgQWxiZXJ0?= Microsoft Access Form Coding 4 14th Feb 2006 06:11 PM
Error Message: Windows cannot find 'box,box,box,box,box' =?Utf-8?B?Ym91Y2hhcmRwaWU=?= Windows XP Help 2 25th Jul 2005 08:47 PM
Make a text box visible if a different text box has text in it =?Utf-8?B?UmljaGFyZA==?= Microsoft Access Form Coding 4 21st Jul 2005 02:06 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:59 PM.