Compare two fields and display amount or message.....

J

Javes

Hi I have no programming skills....

I would like to know if someone has a code for a field I
want to compare: IF Textbox1 is EQUAL to Textbox2 THAN
Textbox3 will display Textbox1 Total OR IF they are not
equal THAN it will display a message "UNBALANCED"

Please assist and if code is available where do I put it
in the Event on update?

Thanks for all your help in adavnce Javes
 
D

Dennis Schmidt

Hi Javes,

My name is Dennis Schmidt. Thank you for using the Microsoft Newsgroups.

Code would be something like the following:

If Me!Textbox1 = Me!textbox2 then
Me!Textbox3 = Me!Textbox1
Else
Me!Textbox3 = "Unbalanced"
End IF

If you want to use this code to populate Textbox3 before you save the
record, you would place the code on the Form's BeforeUpdate event.

I hope this helps! If you have additional questions on this topic, please
reply to this posting.

Need quick answers to questions like these? The Microsoft Knowledge Base
provides a wealth of information that you can use to troubleshoot a problem
or answer a question! It's located at
http://support.microsoft.com/support/c.asp?M=F>.

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2001 Microsoft Corporation. All rights
reserved.

Regards,
Dennis Schmidt
Microsoft Support
 
J

John Vinson

Hi I have no programming skills....

I would like to know if someone has a code for a field I
want to compare: IF Textbox1 is EQUAL to Textbox2 THAN
Textbox3 will display Textbox1 Total OR IF they are not
equal THAN it will display a message "UNBALANCED"

Please assist and if code is available where do I put it
in the Event on update?

Thanks for all your help in adavnce Javes

Are these *fields in a table* (if so you can't do this) or *controls
on a form*?

If the latter, set the Control Source of Textbox3 to:

= IIF([Textbox1] = [Textbox2], [Textbox1], "UNBALANCED")

I'm not sure what you mean by "textbox1 total" though - is this a
continuous form? what are you totalling?
 
J

Javes

Hi John,

I just want to compare two calculations between two text
boxes (which I will keep invisible) and then in a third
text box set a final Dollar Amount or "MESSAGE".

Please assist....all three fields are JUST CALCULATIONS
and UNBOUND.

THanks,

Javes
-----Original Message-----
Hi I have no programming skills....

I would like to know if someone has a code for a field I
want to compare: IF Textbox1 is EQUAL to Textbox2 THAN
Textbox3 will display Textbox1 Total OR IF they are not
equal THAN it will display a message "UNBALANCED"

Please assist and if code is available where do I put it
in the Event on update?

Thanks for all your help in adavnce Javes

Are these *fields in a table* (if so you can't do this) or *controls
on a form*?

If the latter, set the Control Source of Textbox3 to:

= IIF([Textbox1] = [Textbox2], [Textbox1], "UNBALANCED")

I'm not sure what you mean by "textbox1 total" though - is this a
continuous form? what are you totalling?


.
 
J

John Vinson

Hi John,

I just want to compare two calculations between two text
boxes (which I will keep invisible) and then in a third
text box set a final Dollar Amount or "MESSAGE".

Please assist....all three fields are JUST CALCULATIONS
and UNBOUND.

You've lost me. An invisible unbound textbox? Why? It won't have any
usable events. What are the Control Sources of the two textboxes?
 
J

Javes

Sorry omit the invisible part, all would like is just for
two fields to be compared then if they are equal the
third field will display one of the amounts on the
first. If the two fields are NOT equal than display a
message.

This didn't work nothing showed up no error nothing..

If Me!Textbox1 = Me!textbox2 then
Me!Textbox3 = Me!Textbox1
Else
Me!Textbox3 = "Unbalanced"
End IF

THis did work but is missing the ELSE display one of the
totals.

= IIF([Textbox1] = [Textbox2], [Textbox1], "UNBALANCED")

Please and Thanks again, Javes
 
J

John Vinson

Sorry omit the invisible part, all would like is just for
two fields to be compared then if they are equal the
third field will display one of the amounts on the
first. If the two fields are NOT equal than display a
message.

I'm sorry. "one of the amounts on the first"? What does that mean?
(Maybe that I didn't have enough coffee this afternoon...)
This didn't work nothing showed up no error nothing..

If Me!Textbox1 = Me!textbox2 then
Me!Textbox3 = Me!Textbox1
Else
Me!Textbox3 = "Unbalanced"
End IF

What event did you put this code into?
THis did work but is missing the ELSE display one of the
totals.

= IIF([Textbox1] = [Textbox2], [Textbox1], "UNBALANCED")

Please and Thanks again, Javes

There is no "else" in an IIF function; the first argument is a logical
expression; if that expression is TRUE it returns the second argument
- the value in Textbox1 in this case; if FALSE it returns the third.
What are you seeing when the values are equal? What when they are
unequal?

You may need to Requery Textbox3 in the AfterUpdate events of textbox1
and textbox2; or, if these are themselves calculated controls, in the
AfterUpdate event of the controls which go into the calculation of
those textboxes.
 
J

Javes

I really suck...I tried it again and finally after
wasting everyone's time I understand.

Thank you so much for all your precious time.

Sincerely,

Javes
-----Original Message-----
Sorry omit the invisible part, all would like is just for
two fields to be compared then if they are equal the
third field will display one of the amounts on the
first. If the two fields are NOT equal than display a
message.

I'm sorry. "one of the amounts on the first"? What does that mean?
(Maybe that I didn't have enough coffee this afternoon...)
This didn't work nothing showed up no error nothing..

If Me!Textbox1 = Me!textbox2 then
Me!Textbox3 = Me!Textbox1
Else
Me!Textbox3 = "Unbalanced"
End IF

What event did you put this code into?
THis did work but is missing the ELSE display one of the
totals.

= IIF([Textbox1] = [Textbox2], [Textbox1], "UNBALANCED")

Please and Thanks again, Javes

There is no "else" in an IIF function; the first argument is a logical
expression; if that expression is TRUE it returns the second argument
- the value in Textbox1 in this case; if FALSE it returns the third.
What are you seeing when the values are equal? What when they are
unequal?

You may need to Requery Textbox3 in the AfterUpdate events of textbox1
and textbox2; or, if these are themselves calculated controls, in the
AfterUpdate event of the controls which go into the calculation of
those textboxes.


.
 
J

John Vinson

I really suck...I tried it again and finally after
wasting everyone's time I understand.

Thank you so much for all your precious time.

Don't be too hard on yourself Javes! This is wierd and complicated
stuff, nobody gets it all right the first time.

Glad we were able to help!
 

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