Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make calculate button work???? 1

Status
Not open for further replies.

jasonz

Technical User
Jul 2, 2001
7
US
Hello I have a simple question I hope. I need to make a calculate button work. Here is the information I have so far: In my Macro I have ([Forms]![Status of Payment]![Check Amount:]) in the item part and ([Forms]![Status of Payment]![Check Amount:]+[Forms]![Status of Payment]![Text132]) in the expression part. I have the Macro as a (SetValue) at the top in Action column. Well the text 132 box is set as currency and with 2 decimal places and so is the Check Amount field. Well anyway every time I push the macro button it just adds to the left of the decimal and never add the cents to the total currency amount of the Check Amount. Please help me in trying to figure out the way to make it work.
Thanks for your help.
 
You are adding strings and all that will happen is one string wil lbe concatenated to the other. You need make sure the format of the text boxes is General Number so the contents will be treated as numbers. You may also want to use the Val function for added insurance that numeric values will be used.

Val([Forms]![Status of Payment]![Check Amount:]) + Val([Forms]![Status of Payment]![Text132]) Terry

"The greatest obstacle to discovery is not ignorance -- it is the illusion of knowledge." - Daniel J Boorstin
 
Hey, thanks Terry for the advice. Unfortunately it doesn't work still. I did exactly what you said and used the values that you typed above. I ran the macro and it still only adds to the left of the decimal.(whole numbers) and ignores the cents all together now. Before, when it was on currency value it recorded the cents: Ex: If you type 1.30 it would keep 1.30 in the Text132 field, but only add a 1.00 to the Check Amount field. Well now when you type 1.30 it changes it automatically to 1.00 and adds 1.00 to the Check Amount field. If you have any ideas in what I could do to make this work it would be great. Thank you for your time.
 
Val often "looses" parts of a value. I perfer to use Csng or cdbl. In this instance, CCur would probably be the more appropiate conversion. I do not use macros, as they cannot have any error trappping, so implementation of functions within the macro needs to be left to others.

MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
Thanks for the advice MichaelRed. I was wondering do you have any ideas on how I can make a calculating button with what you have said above. I am not to adapt to the method you are talking about, if you could explain it that would be great. Thanks for the help.
 
"[/]
In my Macro I have

([Forms]![Status of Payment]![Check Amount:])

in the item part and

([Forms]![Status of Payment]![Check Amount:]+
[Forms]![Status of Payment]![Text132])

in the expression part. I have the Macro as a (SetValue)
[/i]

If (it is a BIG "IF") I ubderstand the above.

It refers to two (2) taxt boxes on the form. The form has the the two boxes populated from 'stuff' not seen here. When a command button is "clicked", the contents of textbox "Text132" should be added to the the contents of the textbox "Check Amount:"

While not really indicated, I will ASSUME that all these controls reside on a common / single form.

IF (and ONLY IF) the above are true and correct!!!

In design mode of the form. Select the command button and view the properties. Scroll through the properties to the "Click" event. I am GUESSING that you currently have the MACRO as the event here. So click on the combo box dowm arrow for the event and select Procedure. Now click on the elipiss at the right of the combo box. It will open up a module/code window with a 'name' like":

commandX_Click
with the cursor between the lines which say Sub and End Sub

Enter the following

Me.[Check Amount:] = CCur(Me.[Check Ammount:]) + CCUr(Me.[Text132])


Looking at the items in the expression, however raise another question. The "name" of the control "Check Amount:" appears to be in the format normally assigned to a
LABEL CAPRION, not that assigned to a text box. Could you please verify the naems shown are ht eNAMES of text box controls on your form?




MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top