Declare a variable as a percent in VB
Posted on 2004-09-22
I have an access form where the user enters, say, "25" into a control called ProfitSplit, and then I want the value to be displayed as "25%" and stored in the underlying SQL table as 0.25.
The Data Type of the column in the SQL table is Decimal.
The Format of the control on the Access form is General Number, with 2 decimal places showing.
I have an AfterUpdate event on the control which is as follows:
Private Sub ProfitSplit_AfterUpdate()
Dim percent As float
percent = 0
percent = [Forms]![Clientform]![ProfitSplit] / 100
[Forms]![Clientform]![ProfitSplit] = percent
However, the result is that ProfitSplit is always turned into a 0. The problem occurs in the line " percent = [Forms]![Clientform]![ProfitSplit] / 100 " -- basically, percent is not getting the value properly assigned to it. I do not know why...