?
Solved

VBA code help for multiplying values

Posted on 2011-02-17
6
Medium Priority
?
930 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1000 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 1000 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
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, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

752 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