Access & VB

  KW2K 23:50 29 Nov 05
Locked

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.

Regards.

  Access genu 00:37 30 Nov 05

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 05

sorry,
end Sub Should be end Function

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

New Google phones UK release date | Pixel XL price, new features, specifications: Pixel X and…

1995-2015: How technology has changed the world in 20 years

iOS 10 troubleshooting tips: Simple fixes for the most common iOS 10 problems, from network…