mask for number field

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

Guest

I want to use an input mask for a number field, type=single in a form.

I want to input 12.75 as "12-3" where 3 is the numerator, and 4 is always
the denominator.

So:
12.1=12.25
12.2=12.50
12.3=12.75
13.0=13.00

Again, this is a number field, *not* a text field.

How can I do this?

Thank you!
 
Bob,
I want to input 12.75 as "12-3"
(is "12-3" a typo... because your 4 examples later give 12.3 as one of the
possible inputs)
12.1=12.25
12.2=12.50
12.3=12.75
13.0=13.00

I'll assume the 4 examples above are correct as far as what you'll be
entering.

On the AfterUpdate event of the field (ex. NumFld)
NumFld = Int(NumFld) + ((NumFld - Int(NumFld)) * 10 * 0.25)

hth
Al Camp
 
Al,

Thank you for your quick reply.

Intriguing! However, when I browse the table in the form, NumFld will
display as 12.75 instead of 12-3.

Is there a way to mask the field?

-Bob
 
Bob,
I'm confused... let's start over...
Given your numeric field (ex.name of [NumFld] and a value of 12.25)
1. What value do you want to enter into the field on your form? (12.1
or 12.25?)
2. How do you want that value stored in the table? (as 12.25, or as
12.1?)
(Can't do "12-1" in a numeric field)
3. How do you want to display the value? ("12-1"?)
Answer me that... and I'll try to get right back.
hth
Al Camp
 
Al,

A hypothetical example: Assume that Microsoft is traded on NASDAQ in
quarters. That is, the minimum price change is 25cents. This isn't how it is,
but let's assume it is!

I want easy price entry into my Access table, so I want to enter 12-2 and
have Access store that in the table as 12.50.
 
Bob,
You can't enter "12-2" into a numeric field, it's a violation of data
types.
You'll have to accept the value in an unbound field (ex name
[TempNumFld], convert that value to the one you want to store, and update
NumFld accordingly.
I want easy price entry into my Access table, so I want to enter 12-2 and
have Access store that in the table as 12.50.


On the After Update of [TempNumFld]...

Private Sub TempNumFld_AfterUpdate()
NumFld = Val(Left(Test1, InStr(Test1, "-") - 1) + Mid(Test1, InStr(Test1,
"-") + 1) * 0.25)
End Sub

I tested this and it's OK. When you put 12-1 into TempNumFld, it's coverted
to 12.25 and stored in NumFld
hth
Al Camp

Bob said:
Al,

A hypothetical example: Assume that Microsoft is traded on NASDAQ in
quarters. That is, the minimum price change is 25cents. This isn't how it
is,
but let's assume it is!

I want easy price entry into my Access table, so I want to enter 12-2 and
have Access store that in the table as 12.50.




AlCamp said:
Bob,
I'm confused... let's start over...
Given your numeric field (ex.name of [NumFld] and a value of 12.25)
1. What value do you want to enter into the field on your form?
(12.1
or 12.25?)
2. How do you want that value stored in the table? (as 12.25, or
as
12.1?)
(Can't do "12-1" in a numeric field)
3. How do you want to display the value? ("12-1"?)
Answer me that... and I'll try to get right back.
hth
Al Camp
 
Al,

Absolutely great -- and speedy! -- reply.

Ah, there's no clean way to do it, just a kludge. Great ideas, and thanks
for testing!

-Bob

AlCamp said:
Bob,
You can't enter "12-2" into a numeric field, it's a violation of data
types.
You'll have to accept the value in an unbound field (ex name
[TempNumFld], convert that value to the one you want to store, and update
NumFld accordingly.
I want easy price entry into my Access table, so I want to enter 12-2 and
have Access store that in the table as 12.50.


On the After Update of [TempNumFld]...

Private Sub TempNumFld_AfterUpdate()
NumFld = Val(Left(Test1, InStr(Test1, "-") - 1) + Mid(Test1, InStr(Test1,
"-") + 1) * 0.25)
End Sub

I tested this and it's OK. When you put 12-1 into TempNumFld, it's coverted
to 12.25 and stored in NumFld
hth
Al Camp

Bob said:
Al,

A hypothetical example: Assume that Microsoft is traded on NASDAQ in
quarters. That is, the minimum price change is 25cents. This isn't how it
is,
but let's assume it is!

I want easy price entry into my Access table, so I want to enter 12-2 and
have Access store that in the table as 12.50.




AlCamp said:
Bob,
I'm confused... let's start over...
Given your numeric field (ex.name of [NumFld] and a value of 12.25)
1. What value do you want to enter into the field on your form?
(12.1
or 12.25?)
2. How do you want that value stored in the table? (as 12.25, or
as
12.1?)
(Can't do "12-1" in a numeric field)
3. How do you want to display the value? ("12-1"?)
Answer me that... and I'll try to get right back.
hth
Al Camp
 
Well, now that I'm stuck with text fields that have to be converted to number
fields after the fact, then I can use lookup tables for input. One text field
for the integer portion and another text field for the fraction portion.
Even better than using masks!

Again, thank you for your help!
-Bob
 
ggg
Bob said:
Al,

A hypothetical example: Assume that Microsoft is traded on NASDAQ in
quarters. That is, the minimum price change is 25cents. This isn't how it is,
but let's assume it is!

I want easy price entry into my Access table, so I want to enter 12-2 and
have Access store that in the table as 12.50.




AlCamp said:
Bob,
I'm confused... let's start over...
Given your numeric field (ex.name of [NumFld] and a value of 12.25)
1. What value do you want to enter into the field on your form? (12.1
or 12.25?)
2. How do you want that value stored in the table? (as 12.25, or as
12.1?)
(Can't do "12-1" in a numeric field)
3. How do you want to display the value? ("12-1"?)
Answer me that... and I'll try to get right back.
hth
Al Camp
 
Back
Top