Solved

VBA code help for multiplying values

Posted on 2011-02-17
6
897 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 119

Accepted Solution

by:
Rey Obrero 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 119

Expert Comment

by:Rey Obrero
ID: 34915523
no need to use two textboxes, one will do.
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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 119

Expert Comment

by:Rey Obrero
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
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…

867 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now