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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Allowing text to be typed into either of two text boxes 1

Status
Not open for further replies.

scottyjohn

Technical User
Nov 5, 2001
523
0
0
GB
Hi all,
I have a form with three text boxes. The first is a bound text box to a field SALE_SUBTOTAL in a table where I ultimately store the form contents as a new record. Under this text box, I have two other text boxes, one which contains the expression =[SALE_SUBTOTAL]*0.2, which displays the VAT for the transaction, and then a third which has =[SALE_SUBTOTAL]*1.2, which is the total including VAT to charge the customer.

So currently, user types the sub total into the SALE_SUBTOTAL box, and the other two boxes are automatically displayed and all works fine. However Ive been asked if its possible to also allow them to type in the grand total box, the one with =[SALE_SUBTOTAL]*1.2 in there, and automatically populate the SALE_SUBTOTAL textbox and the VAT textbox with the relevant backwards calculations. I cant figure out if this is possible and if it is, how would I go about doing this?

Any help much appreciated!

John
[smile]
 
A calculated control, cannot also accept inputs. The easiest would be another seperate "backward calculation" text box and a button to trigger the update event.

The code would then be
me.SALE_SUBTOTAL = me.txtBoxBackwardCalculation / 1.2
 
Another method would be to add a CALCULATE button and do all the calculations in VBA.
Enter data in whichever text box you want, click the button, and let your code populate the other two.


Randy
 
Hmm thanks guys for the two possible methods. Randy, how would that code look roughly?

John
[smile]
 
Something like... (not tested)

Code:
If txtSaleSubtotal > 0 Then
    txtVAT = txtSaleSubtotal * 0.2
    txtTotal = txtSaleSubtotal * 1.2
Else
    If txtTotal > 0 Then
        txtSaleSubtotal = txtTotal / 1.2
        txtVAT = txtSaleSubtotal * 0.2.

Randy
 
Great Randy, took your route and its working perfectly. Thanks again to both you guys for responding

John
[smile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top