setting decimal points

D

DBane

On my data form I am entering figures . Example the first box 24.68, the
second box 48.10, the third entry has two choices say 57.88 or 111.43, the
4th entry also has two choices say 59.60 or 135.50 . I am trying to
eliminate having to repeatly place the decimal 2 places to the right . What I
am trying to do is enter 2468 and get the result when entered to be 24.68 .
How would I set this up to function in this manner.
 
S

Steve Schapel

DBane,

You could achieve this by putting code like this on the After Update
event of each control...
Me.NameOfTextbox = Me.NameOfTextbox / 100

If you do it like this, there are certiain things you would need to take
into account. For example, if you needed to change an already entered
figure, you would have to enter the new figure in full rather than
editing the existing entry.
 
D

DBane

Thank for your reply, this will definetly work. the only problem is that I am
a foolish Polish truck driver from Pittsburgh, that should explain it all. I
have gone through two levels of access training and have the manuals. So my
expertise is minium. If possible could you walk me through the steps. Should
the changes be made on the properties sheet in the design view ,or the form
in design view.
 
S

Steve Schapel

DBane,

Well, I was a bus driver for a number of years, and I've got a Polish
friend, but I wouldn't have a clue where or what Pittsburgh is, so I'd
say we should be able to get something going on that basis. :)

In the design view of the form, select one of the textboxes, and open
the property sheet. Locate the After Update event property. Enter
[Event Procedure] and then click the little ellipsis (...) button at the
right. This should take you to the VB Editor window, with something
like the following already entered...
Private Sub Text1_AfterUpdate()

End Sub
.... with the cursor located in the gap between the two lines. Type the
statement I showed you before into the gap, so that it looks like this...
Private Sub Text1_AfterUpdate()
Me.NameOfTextbox = Me.NameOfTextbox / 100
End Sub
Of course, you replace the 'NameOfTextbox' with the, well, name of the
textbox.
Then close the VBE window, save the form, open in form view, and give it
a try.
 
D

DBane

Thank you for your help! Worked good!



Steve Schapel said:
DBane,

Well, I was a bus driver for a number of years, and I've got a Polish
friend, but I wouldn't have a clue where or what Pittsburgh is, so I'd
say we should be able to get something going on that basis. :)

In the design view of the form, select one of the textboxes, and open
the property sheet. Locate the After Update event property. Enter
[Event Procedure] and then click the little ellipsis (...) button at the
right. This should take you to the VB Editor window, with something
like the following already entered...
Private Sub Text1_AfterUpdate()

End Sub
.... with the cursor located in the gap between the two lines. Type the
statement I showed you before into the gap, so that it looks like this...
Private Sub Text1_AfterUpdate()
Me.NameOfTextbox = Me.NameOfTextbox / 100
End Sub
Of course, you replace the 'NameOfTextbox' with the, well, name of the
textbox.
Then close the VBE window, save the form, open in form view, and give it
a try.

--
Steve Schapel, Microsoft Access MVP
Thank for your reply, this will definetly work. the only problem is that I am
a foolish Polish truck driver from Pittsburgh, that should explain it all. I
have gone through two levels of access training and have the manuals. So my
expertise is minium. If possible could you walk me through the steps. Should
the changes be made on the properties sheet in the design view ,or the form
in design view.
 
D

DBane

Hey,
Whats goin on. That pain in the neck truck driver again. Hope you have got
a long weekend and are enjoying it. If you can,when you get some time, maybe
you can help me with some number formatting. I am trying to speed up my
entries on the form again. I want to enter the distance say 1 and
1/16m(mile). The default setting is changing to the date format if I do not
use the m(mile). How do I change my settings to get the fractional style.
11/16. That will eliminate the need of entering the m each entry.

Thank you.
: Dave
 
S

Steve Schapel

Dave,

There are a number of questions to consider here.

I assume the textbox on the form is bound to a field in your table? If
so, what is the data type of the field? It seems peculiar to me that
Access would interpret yur entry as a date unless the field is a
Date/Time data type. And I imagine Access would not allow you to enter
with a 'm' unless it is a Text data type. But in any case, you have to
consider whather you need the Distance to be regarded as a numerical
value. This would apply, for example, if you want to do calculations of
any sort, for example get total distances, or averages, or work out fuel
consumption, or some such. If so, then your Distance field should be
defined as a Number data type. And if it's a number data type, well, as
far as I know, you can't format the control to display as a fractional
format. You would either need to use a decimal entry, or else set up
two distance fields, one for the whole miles and the other for the
fractional portion. So if you always want to record the distance to the
nearest 1/16th of a mile, you would have a textbox for whole miles and
another for 16ths, so if the distance was 2¼ miles, you would enter 2 in
the miles box, and 4 in the 16ths box. But then, when you are doing
your calculations, you will need to use a formula to join these together
again, like this...
FullDistance: [DistanceMiles]+[Distance16ths]/16
and Access is still going to work it out as a decimal value.

So, in other words, it is not straightforward, and the way to proceed
will depend on your requirements.
 
D

DBane

Steve,
in the reply you sent, it had the look I was looking for. The 2 1/4. How
did you enter that figure to get the fractional look, the little 1/4.
Steve Schapel said:
Dave,

There are a number of questions to consider here.

I assume the textbox on the form is bound to a field in your table? If
so, what is the data type of the field? It seems peculiar to me that
Access would interpret yur entry as a date unless the field is a
Date/Time data type. And I imagine Access would not allow you to enter
with a 'm' unless it is a Text data type. But in any case, you have to
consider whather you need the Distance to be regarded as a numerical
value. This would apply, for example, if you want to do calculations of
any sort, for example get total distances, or averages, or work out fuel
consumption, or some such. If so, then your Distance field should be
defined as a Number data type. And if it's a number data type, well, as
far as I know, you can't format the control to display as a fractional
format. You would either need to use a decimal entry, or else set up
two distance fields, one for the whole miles and the other for the
fractional portion. So if you always want to record the distance to the
nearest 1/16th of a mile, you would have a textbox for whole miles and
another for 16ths, so if the distance was 2¼ miles, you would enter 2 in
the miles box, and 4 in the 16ths box. But then, when you are doing
your calculations, you will need to use a formula to join these together
again, like this...
FullDistance: [DistanceMiles]+[Distance16ths]/16
and Access is still going to work it out as a decimal value.

So, in other words, it is not straightforward, and the way to proceed
will depend on your requirements.

--
Steve Schapel, Microsoft Access MVP

Hey,
Whats goin on. That pain in the neck truck driver again. Hope you have got
a long weekend and are enjoying it. If you can,when you get some time, maybe
you can help me with some number formatting. I am trying to speed up my
entries on the form again. I want to enter the distance say 1 and
1/16m(mile). The default setting is changing to the date format if I do not
use the m(mile). How do I change my settings to get the fractional style.
11/16. That will eliminate the need of entering the m each entry.
 
S

Steve Schapel

Dave,

You can use the Character Map (in Windows XP you go Start=>All
Programs=>Accessories=>System Tools) to see that most fonts support a
large number of non-keyboard characters. You can get ¼ by holding down
the Alt key, and then using the numeric keypad to type 0188. Or else
copy/paste from the Character Map. Many fonts also provide ½, ¾, ⅛, ⅜,
â…, â…ž. However, these are text characters, not numeric, so you can't
enter them directly into a database field and expect to use them in
calculations. It would be possible to set up a table with these
fractional characters in one field, and the corresponding numerical
values in another field, and enter them on a form using a combobox, such
that the fractional character is what is displayed on the form, but the
associated numerical value is what is bound to the data field. There
are probably some fonts which also support other fractional characters
like 16ths, but I don't know what they are.
 
D

DBane

I have a field named surface . For a dirt or turf race. D is entered dirt and
a t for turf. 80% of the races are run on dirt. how would I make the default
setting in the form d. so I can just enter the T whenever I post the turf
result.
 
C

chenjinna123

" have a field named surface . For a dirt or turf race. D is entered dirt
and
a t for turf. 80% of the races are run on dirt. how would I make the default
setting in the form d. so I can just enter the T whenever I post the turf
result.
 
Top