displaying the result of a calculation on another form

L

lynn atkinson

I have a text box which calculates the number of places left available on a
training course. the calculation is as follows

=IIf([room capacity]=Null,[max participants]-[text30],IIf([room
capacity]<[max participants],([room capacity]-[text30]),([max
participants]-[Text30])))

Can I just display this text box on another form with out working out the
calculation again?
If not, how do I make the calculation refer to the correct fields on the
other form?

hope this makes sense
 
G

Guest

hi,
in the second forms record source, you could try
[Forms]![otherform]![textboxcalc]
but both forms would have to be open.
 
G

Guest

hi again,
correction.
on the second form, in the textbox record source try
[Forms]![otherform]![textboxcalc]
sorry bout that.
-----Original Message-----
hi,
in the second forms record source, you could try
[Forms]![otherform]![textboxcalc]
but both forms would have to be open.
-----Original Message-----
I have a text box which calculates the number of places left available on a
training course. the calculation is as follows

=IIf([room capacity]=Null,[max participants]-[text30],IIf ([room
capacity]<[max participants],([room capacity]-[text30]), ([max
participants]-[Text30])))

Can I just display this text box on another form with
out
working out the
calculation again?
If not, how do I make the calculation refer to the correct fields on the
other form?

hope this makes sense


.
.
 
L

lynn atkinson

Sorry, I cant see the difference between your 2 posts? anyway, I have put it
in to practice, and am getting a value, but it is the value of the first
record in the first form. How do I qualify the statement so that it displays
the value for that one course (event) (form and subform are linked by event
ID).



hi again,
correction.
on the second form, in the textbox record source try
[Forms]![otherform]![textboxcalc]
sorry bout that.
-----Original Message-----
hi,
in the second forms record source, you could try
[Forms]![otherform]![textboxcalc]
but both forms would have to be open.
-----Original Message-----
I have a text box which calculates the number of places left available on a
training course. the calculation is as follows

=IIf([room capacity]=Null,[max participants]-[text30],IIf ([room
capacity]<[max participants],([room capacity]-[text30]), ([max
participants]-[Text30])))

Can I just display this text box on another form with
out
working out the
calculation again?
If not, how do I make the calculation refer to the correct fields on the
other form?

hope this makes sense


.
.
 
J

John Vinson

I have a text box which calculates the number of places left available on a
training course. the calculation is as follows

=IIf([room capacity]=Null,[max participants]-[text30],IIf([room
capacity]<[max participants],([room capacity]-[text30]),([max
participants]-[Text30])))

Can I just display this text box on another form with out working out the
calculation again?

You SHOULD do the calculation again, to be sure that it's getting the
right data.
If not, how do I make the calculation refer to the correct fields on the
other form?

The calculation should be based on fields in a Table, not textboxes on
a Form; the Form contains no data in its own right! It's just a window
for interacting with data in the tables.

If your second form is referencing the appropriate tables and records
in those tables, the same expression can be used there as on the first
form. Whatever is in [text30] needs to be stored in a Table or
recalculated from data in a Table; otherwise you cannot be sure that
it's correct, or that the form containing it is even open!

Note that your IIF statement WILL NOT WORK correctly. Null is a funny
beast: it means "this value is unknown, undefined, it could be
anything or nothing". As such the expression [room capacity] = Null
will return NULL - not true, not false, but Null - *whatever* is in
[room capacity]. Instead use

Iif(IsNull([room capacity], ...


John W. Vinson[MVP]
 
L

lynn atkinson

just trying to put this in place, but am getting the 'wrong number of
arguements'. not sure where to close the first bracket from the IsNull([room
capacity],.... have tried many combinations

my statement now stands as
=IIf(IsNull([room capacity]),[rooms]![max
participants]-[text1010],IIf([rooms]![room capacity]<[rooms]![max
participants],([rooms]![room capacity]-[text1010]),([rooms]![max
participants]-[Text1010])))

but I know I have the first closing bracket in the wrong place (after [room
capacity])

Any ideas

and any pointers where I can get good documentation on this subject. I am
working blind here with the help of the newsgroup.

John Vinson said:
I have a text box which calculates the number of places left available on a
training course. the calculation is as follows

=IIf([room capacity]=Null,[max participants]-[text30],IIf([room
capacity]<[max participants],([room capacity]-[text30]),([max
participants]-[Text30])))

Can I just display this text box on another form with out working out the
calculation again?

You SHOULD do the calculation again, to be sure that it's getting the
right data.
If not, how do I make the calculation refer to the correct fields on the
other form?

The calculation should be based on fields in a Table, not textboxes on
a Form; the Form contains no data in its own right! It's just a window
for interacting with data in the tables.

If your second form is referencing the appropriate tables and records
in those tables, the same expression can be used there as on the first
form. Whatever is in [text30] needs to be stored in a Table or
recalculated from data in a Table; otherwise you cannot be sure that
it's correct, or that the form containing it is even open!

Note that your IIF statement WILL NOT WORK correctly. Null is a funny
beast: it means "this value is unknown, undefined, it could be
anything or nothing". As such the expression [room capacity] = Null
will return NULL - not true, not false, but Null - *whatever* is in
[room capacity]. Instead use

Iif(IsNull([room capacity], ...


John W. Vinson[MVP]
 

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