why in god's name won't calculated controls work?

S

Stahlhelm

I have been trying to no avail to create a calculated field on a form
I have used the expression builder, I have typed in code manually, I have
tried using full table and field name syntax all without success.

In the control source I have
=[transactions]![amount] * 2
The table and field names are correct ( they appear in the expression
builder) and the amount field is a number data type.
All this produces is #name? in the form field
Every book and website I have consulted tells me that this should work.
I am getting incredibly fed up with this pathetic useless software
can someone please tell me why this will not work.
Thanks in advance
 
R

Rob Parker

I suspect that it's failing because the name of the textbox control is
"amount". You probably built the form by drag-n-drop, and this was
originally the control to display the [amount] field,so its default name is
"amount". Access is confused because the field name and the control name
are the same, and will display the #name? error in that case. Try renaming
your control.

HTH,

Rob
 
K

Ken Snell \(MVP\)

Is the "amount" field from the "transactions" table in the form's
RecordSource query? If not, the calculated field will not work -- you must
use the DLookup function instead. See Help for info about it.
 
K

Keith Wilby

Stahlhelm said:
I have been trying to no avail to create a calculated field on a form
I have used the expression builder, I have typed in code manually, I have
tried using full table and field name syntax all without success.

In the control source I have
=[transactions]![amount] * 2
The table and field names are correct ( they appear in the expression
builder) and the amount field is a number data type.
All this produces is #name? in the form field
Every book and website I have consulted tells me that this should work.
I am getting incredibly fed up with this pathetic useless software
can someone please tell me why this will not work.
Thanks in advance

I would suggest binding your form to a query and performing the calculation
in the query rather than on the form.

Keith.
www.keithwilby.com
 
A

Albert D. Kallal

I not sure where you got the idea that you can, or need a table qualifier
for expression in text box on a form. You not find ONE example anywhere on
the internet that even suggests as such.

It is a RARE day when you actually will use the table name in a control on a
form. (don't confuse building expressions in sql, or in the query builder
and that of controls on a form).

The form is going to be based on a table, or query...that is ALL!!!

Your expressions are thus limited to fields/values in that query or table.

So, assuming your form has a underlying field called amount, then your
expression should be:

=([amount] * 2)

That is all you should need.

If you have query that joins in more then one table, then you can ONLY use a
table qualifier if there is a name conflict.

It will be:

=([ctest_1.amount]*2)

Notice here again that the [] brackets are around the whole expression.

To create your expression, I would place a text box on the screen. (make
sure the text name is NOT amount, as then ms-access will get confused
here -- and, check YOUR name for the text control...it can't be "amount", as
then ms-access will get confused as to if you referenced a field, or control
named "amount"...which one will ms-access use? -- it can't know!!!). So, if
you going to place a text box on a form, and use a calculated control, MAKE
SURE the name of the control does not CONFLICT with existing field names in
the underlying data used.

Now, in the data tab for this text box, select the amount field.

You likely have for the data source something like

amount

Now, just edit the above to become

=([amount] * 2)

The reason why I suggesting you FIRST select the amount from the combo drop
down is to ENSURE that you correctly selected the amount field. Now, test
the form, and ensures it displays the amount. ONLY ATTEMPT TO EDIT THIS
CONTROL AFTER YOU HAVE SUCCESSFULLY DISPLAYED THE AMOUNT AND YOU KNOW IT
WORKS!!!.

So, flip the form into view mode...does it display the amount correctly?
Only THEN should move on to the next step of your calculations. Now, re-edit
the "amount" expression to

=([amount] * 2)

Now, if the field value your trying to display is actually from another
table, then you have to use a different approach. And, you have to specify
what record from the other table you want to display in this case also. And,
of course, when you attempted to use legal field values to set the control
source, you ONLY see values from the current forms underlying data. So, you
*can* display data from another table, but you have to as mentioned use a
function like dlookup() to retrieve this value (and further you have to
specify what field and record to retrieve from that other table).
I am getting incredibly fed up with this pathetic useless software

You know, normally I would have a real snide remark here. I going to be a
gentleman, and lets just leave this alone. Don't blame the tool because you
don't know it yet. Simply take the time and make the effort to learn the
tool.....ok?
 
M

missinglinq via AccessMonster.com

Is [Amount] present on your form? If so,

= [amount]*2

should work.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 

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