Performing Calculations in a label

U

Umm Husina

I want to have a label that gives the difference of the values in two text
boxes. For example:

Number_visits and Visits_used are textboxes with number values, and I want
to write something like this in the caption of the label:

=[Number_visits] - [Visits_used]
All I get when I view the form is the line of text I typed above. Am I
missing some part of the syntax like Number_visits.txt or ""?

I would appreciate a hint or help, Thanks.
 
R

RBear3

Not sure about doing it in a label, but you could create a text box and
place it in the text box.
 
F

fredg

I want to have a label that gives the difference of the values in two text
boxes. For example:

Number_visits and Visits_used are textboxes with number values, and I want
to write something like this in the caption of the label:

=[Number_visits] - [Visits_used]
All I get when I view the form is the line of text I typed above. Am I
missing some part of the syntax like Number_visits.txt or ""?

I would appreciate a hint or help, Thanks.

Label controls cannot be used to perform calculation.
Use an Unbound Text control.
Set it's control source to:

=[Number_Visits]-[Visits_used]

Make sure the name of this control is not the same as the name of any
field used in the expression.
 
G

gumby

I want to have a label that gives the difference of the values in two text
boxes. For example:

Number_visits and Visits_used are textboxes with number values, and I want
to write something like this in the caption of the label:

=[Number_visits] - [Visits_used]
All I get when I view the form is the line of text I typed above. Am I
missing some part of the syntax like Number_visits.txt or ""?

I would appreciate a hint or help, Thanks.

Replace the label with a text box. Them copy your code into the
control sourse of the text box. You can format the text box just like
your label. Also when you add the text box, just delete the associated
label.

David
 
S

Steve

Put the following code in the AfterUpdate event of both textboxes:
Me!LabelName.Caption = NZ(Me![Nimber_Visits],0) - NZ(Me![Visits_Used],0)

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
K

Keith Wilby

fredg said:
Label controls cannot be used to perform calculation.

Something like this would work in a form's current event:

Me.Label0.Caption = Me.txtBox1 - Me.txtBox2

Keith.
 

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