Performing Calculations in a label

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
Not sure about doing it in a label, but you could create a text box and
place it in the text box.
 
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.
 
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
 
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)
 
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.
 
Back
Top