Solved

VBA code help for multiplying values

Posted on 2011-02-17
6
908 Views
Last Modified: 2012-05-11
Hello all,

I need help with two sets of code as I am undecided which option to go with yet.

First code - If I enter a value into text box "txt_cb_two_enter" then the text box "text_cb_two_result" displays the value from "txt_cb_two_enter" mutiplied by 500.  So 1 is entered in the first box and 500 is displayed in the second box.

Second code - If I enter a value into text box "txt_cb_two" then the value is mutiplied by 500 and the result is displayed in the same text box but as currency.  So 1 is entered in the box and £500 is displayed.

Thanks in advance.

Chris
0
Comment
Question by:smods
  • 3
  • 2
6 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 250 total points
ID: 34915430
use the afterupdate event of  "txt_cb_two"

private sub txt_cb_two_afterupdate

me.txt_cb_two.value=me.txt_cb_two * 500

end sub
0
 
LVL 19

Assisted Solution

by:MINDSUPERB
MINDSUPERB earned 250 total points
ID: 34915471
Chris,

Try this one:

Private Sub txt_cb_two_enter_AfterUpdate()
Me.txt_cb_two_result = Me.txt_cb_two_enter.Value * 500
End Sub
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34915523
no need to use two textboxes, one will do.
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

Author Comment

by:smods
ID: 34915552
Yeah thanks both for your input!

I haven't decided on my final approach for the job in hand yet capricorn1.  

My users may want to go with two boxes so they can see the initial value they have entered.  If I was to go with a single box approach what would the code be to change the field type to currency from a number?

Regards

Chris
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34915557
just set the format of the textbox to currency
0
 

Author Closing Comment

by:smods
ID: 34915817
I'm still not sure which I'll be going with but both work :)

Thanks

Chris
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question