%properties on access form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an access form used for data entry, in certain feilds I have to fill
in a persentage - 50% 20%etc. I want the % to automatically fill in when I
type in a number(50) It does this, however when I tab to the next feild it
changes to 5000%. Can someone tell me what the properties have to be set at
in order for it to come out the way I need? Or if there is some other
setting that is wrong? Thanks for help...Veronica
 
The problem is a percentage is a fraction so it is
expecting .5 not 50. If you want it to use your 50 then
try putting code in the OnChange event that does somehting
like this:

If isnumeric(txtInput) Then
txtInput=txtInput & "%"
End if
or
If isnumeric(txtInput) Then
txtInput=format(txtInput/100, "0.00%")
End if

-Cameron Sutherland
 
Veronica said:
I have an access form used for data entry, in certain feilds I have
to fill in a persentage - 50% 20%etc. I want the % to automatically
fill in when I type in a number(50) It does this, however when I tab
to the next feild it changes to 5000%. Can someone tell me what the
properties have to be set at in order for it to come out the way I
need? Or if there is some other setting that is wrong? Thanks for
help...Veronica

The thing is, the "Percent" format property is just that -- a format,
not a statement of how data entry is to be interpreted. Unless you use
code to fix it up (which I usually do) entries must either include the
percent sign (e.g., the user enters "50%") or else must be made as
decimal fractions (e.g., the user enters .50 to get "50%" to be
displayed).

What I usually do is use code in the text box's AfterUpdate event that
reinteprets the user's entry based on its plausibility as a percent --
if it's greater than 1, I assume the user meant to enter it as a
percent. For example,

'----- start of example code -----
Private Sub PosFraction_AfterUpdate()

' Correct entry of percent values without percent sign.
If Me.PosFraction > 1 Then
Me.PosFraction = Me.PosFraction / 100
End If

End Sub

'----- end of example code -----

Of course, that only works when 100% is the maximum value the user could
plausibly be entering.
 
Cameron,
Thankyou for your reply. This is what I did and what happened based on your
instruction (please bare with me as I am an access beginner);

In properties/events I typed in - If isnumeric(txtInput) Then
txtInput=txtInput & "%" End if

I tryed the other one as well. I got a pop up that said the macro does not
exist or is new and not saved???? Where do I go from here????
 
Back
Top