Control source SUM in text box loses brackets "[]" and gives#error

G

Guest

I create a new text box and in the control source I enter =Sum([Cost]) and it
works fine but when I save and close the form and then reopen it the square
brackets "[]" have gone and the text box shows #error.

Adding back the square brackets fixes the problem but it is gone each time I
open the form.

Can anyone help? Thanks in advance.
 
W

Wayne Morgan

Is there also a control called Cost? You are referring to the field in the
Sum() statement. Usually, this will give a #Name error, but with this inside
the Sum() function, you may just get #Error.
 
G

Guest

What should be in the square brackets is the control source of the control
that you're referring to.
 
G

Guest

Hi,

Thanks for your reply. In the square brackets is the field name of the
field that I am trying to sum. It all works when I put the square brackets
around the field name but somehow the brackets get deleted when I close the
form.

Danny said:
What should be in the square brackets is the control source of the control
that you're referring to.

Snowstar said:
I create a new text box and in the control source I enter =Sum([Cost]) and it
works fine but when I save and close the form and then reopen it the square
brackets "[]" have gone and the text box shows #error.

Adding back the square brackets fixes the problem but it is gone each time I
open the form.

Can anyone help? Thanks in advance.
 
G

Guest

Thanks for your help. The field is called Cost and I am trying to sum this
field. There is a text box called "Cost" which was created to display the
Cost field when I used the form wizard. I am new to using Access and am not
entirely sure what the control source is other than it is the source of the
data in the text box. Is this correct?

Wayne Morgan said:
Is there also a control called Cost? You are referring to the field in the
Sum() statement. Usually, this will give a #Name error, but with this inside
the Sum() function, you may just get #Error.

--
Wayne Morgan
MS Access MVP


Snowstar said:
I create a new text box and in the control source I enter =Sum([Cost]) and
it
works fine but when I save and close the form and then reopen it the
square
brackets "[]" have gone and the text box shows #error.

Adding back the square brackets fixes the problem but it is gone each time
I
open the form.

Can anyone help? Thanks in advance.
 
W

Wayne Morgan

Try changing the name of the textbox to txtCost so that it has a different
name than the field. Replace the brackets in your code line and see if it
works properly.

--
Wayne Morgan
MS Access MVP


Snowstar said:
Thanks for your help. The field is called Cost and I am trying to sum
this
field. There is a text box called "Cost" which was created to display the
Cost field when I used the form wizard. I am new to using Access and am
not
entirely sure what the control source is other than it is the source of
the
data in the text box. Is this correct?

Wayne Morgan said:
Is there also a control called Cost? You are referring to the field in
the
Sum() statement. Usually, this will give a #Name error, but with this
inside
the Sum() function, you may just get #Error.

--
Wayne Morgan
MS Access MVP


Snowstar said:
I create a new text box and in the control source I enter =Sum([Cost])
and
it
works fine but when I save and close the form and then reopen it the
square
brackets "[]" have gone and the text box shows #error.

Adding back the square brackets fixes the problem but it is gone each
time
I
open the form.

Can anyone help? Thanks in advance.
 
G

Guest

Hi Wayne,

Thanks for your help. I tried the suggestion and renamed the text box to be
"RateBox" and it did not make any difference. I still lost the brackets
after saving and exiting the form and then going back. I also lose the
brackets if I switch between design and form view.

Thanks, Richard

Wayne Morgan said:
Try changing the name of the textbox to txtCost so that it has a different
name than the field. Replace the brackets in your code line and see if it
works properly.

--
Wayne Morgan
MS Access MVP


Snowstar said:
Thanks for your help. The field is called Cost and I am trying to sum
this
field. There is a text box called "Cost" which was created to display the
Cost field when I used the form wizard. I am new to using Access and am
not
entirely sure what the control source is other than it is the source of
the
data in the text box. Is this correct?

Wayne Morgan said:
Is there also a control called Cost? You are referring to the field in
the
Sum() statement. Usually, this will give a #Name error, but with this
inside
the Sum() function, you may just get #Error.

--
Wayne Morgan
MS Access MVP


"Snowstar" <richard at snowstar dot net> wrote in message
I create a new text box and in the control source I enter =Sum([Cost])
and
it
works fine but when I save and close the form and then reopen it the
square
brackets "[]" have gone and the text box shows #error.

Adding back the square brackets fixes the problem but it is gone each
time
I
open the form.

Can anyone help? Thanks in advance.
 
W

Wayne Morgan

Try creating a new textbox (the one you're using the Sum() in) and see if
that helps. There may be something corrupted with the current one. Try
creating a new form and bind it to the same Record Source as the current
form and try the Sum() there.
 

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

Similar Threads


Top