Access & VB

  KW2K 23:50 29 Nov 2005

Hi, I'm wondering if anyone can tell me the code in VB to carry out the folowing function. What I've got is this: In access I've created a table, On a form I've got a text box with a price in it, next to that I've got a text box with a discount in it, and next to that I've got the text box with a Total cost i.e. (price less the discount). I've created a command button on the form and when this is clicked it will output the total cost into my table which I created earlier. I'm sure it can be done in VBA within Access but not sure how. Any help would be much appreciated.


  Access genu 00:37 30 Nov 2005

OK lets take it that we have a text box for price (txtPirce) and a text box for discount (txtDis) that will update a text box for the final price (txtFinal)

Write a function called UpdatePrice

Public Function UpdatePrice
‘Check we have both entities
If trim(" " & txtPrice) = "" OR trim(" " & txtDis) = "" then
Exit sub
End if
txtFinal = txtPrice – (txtPrice * (txtDis\100))
end sub

Now in the after update event on both text boxes type in =UpdatePrice

  Access genu 00:38 30 Nov 2005

end Sub Should be end Function

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

Xiaomi Mi Mix 2 review

Halloween Photoshop & Illustrator tutorials: 20 step-by-step guides to creating spook-tacular…

iPhone X news: Release date, price, new features & specs

Comment créer, modifier et réinitialiser un compte Apple ?