473,320 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

fraction number format?

How can a numeric field display results in fractions? If my recipe data
requires 1/2 cup of something, for example, I'm willing to punch in 0.5 in
the quantity field then select cup in the unit field, but it is more
aesthetically cool to display the number like any paper cook book would--in
plain old regular fractions. I didn't see a format to select to show
fractions. Excel has no problem displaying fractions. Any ideas?

Thanks.
Jun 30 '06 #1
7 15725
On Fri, 30 Jun 2006 16:47:52 GMT, Richard Hollenbeck wrote:
How can a numeric field display results in fractions? If my recipe data
requires 1/2 cup of something, for example, I'm willing to punch in 0.5 in
the quantity field then select cup in the unit field, but it is more
aesthetically cool to display the number like any paper cook book would--in
plain old regular fractions. I didn't see a format to select to show
fractions. Excel has no problem displaying fractions. Any ideas?

Thanks.


Access does not support 1/2 as a number. Either use 0.5 instead or
make the field a Text datatype, which will not allow easy recipe
doubling.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Jun 30 '06 #2
> Access does not support 1/2 as a number. Either use 0.5 instead or
make the field a Text datatype, which will not allow easy recipe
doubling.
--
Fred


Thanks, Fred.

I suppose I could figure out a way to programmatically simulate fractions in
reports, but it will still be a pain in the butt to do data entry unless I
kept a calculator handy to quickly convert fractions into decimals.
Probably a simpler way would be to just leave it alone and whenever I need a
nice printout I could analyze the reports with Word then manually change
them there.

Rich
Jun 30 '06 #3
"Richard Hollenbeck" <ri****************@verizon.net> wrote in message
news:YAcpg.39$9a3.38@trnddc07...
How can a numeric field display results in fractions? If my recipe data
requires 1/2 cup of something, for example, I'm willing to punch in 0.5 in
the quantity field then select cup in the unit field, but it is more
aesthetically cool to display the number like any paper cook book would--in plain old regular fractions. I didn't see a format to select to show
fractions. Excel has no problem displaying fractions. Any ideas?

Thanks.

What if you create another text control on the form and/or report. The value
for this text control can be calculated as a function of the quantity field.
Air code below:

Public Function Qty2 (Mqty As Double) As String
' Get decimal portion of quantity
Mdec = Mqty - Int(Mqty)

Select Case Mdec
Case 0.25
Qty2 = Ctext(Int(Mqty)) & " 1/4"
Case 0.50
Qty2 = Ctext(Int(Mqty)) & " 1/2"
Case 0.75
Qty2 = Ctext(Int(Mqty)) & " 3/4"
Case Else
Qty2 = Ctext(Mqty)
End Select

You could add Case stmts for the 'eighths' if necessary.
Probably the 'quarters' is sufficient.

Fred Zuckerman

Jun 30 '06 #4
Look into CHR$(). I know there are ASCII characters that will diplay
fractions, and you can return the values to a form or report using an
"IIF" statement (i.e.:

IIF(MyVal = "0.5", CHR$(x), MyVal)

or something along those lines.

Jun 30 '06 #5
I haven't memorized the ASCII table but I remember seeing a few fraction
characters in there. I don't think it has fractions for 1/8 and 1/16 and
1/3, etc., but I think I do remember seeing 1/4 and 1/2. I'm currently
using IIF() statements but it gets so complicated because I have to nest
multiple IIF() statements into one larger IIF() statement. Since I have so
many possibilities (i.e., 1/4, 1/3, 1/4, 1/8, 1/16, etc.) I think a case
statement would be easier to read and troubleshoot than nested IIF()
statements.

My big problem was forgetting a basic principle of using unbound textboxes
and storing the data in variables that could later be used in a query.

Thanks,

Rich
"ManningFan" <ma********@gmail.com> wrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Look into CHR$(). I know there are ASCII characters that will diplay
fractions, and you can return the values to a form or report using an
"IIF" statement (i.e.:

IIF(MyVal = "0.5", CHR$(x), MyVal)

or something along those lines.

Jul 1 '06 #6
----- Original Message -----
From: "Fred Zuckerman" <Zu********@sbcglobal.net>
Newsgroups: comp.databases.ms-access
Sent: Friday, June 30, 2006 12:25 PM
Subject: Re: fraction number format?
What if you create another text control on the form and/or report. The
value
for this text control can be calculated as a function of the quantity
field.
Air code below:

Public Function Qty2 (Mqty As Double) As String
' Get decimal portion of quantity
Mdec = Mqty - Int(Mqty)

Select Case Mdec
Case 0.25
Qty2 = Ctext(Int(Mqty)) & " 1/4"
Case 0.50
Qty2 = Ctext(Int(Mqty)) & " 1/2"
Case 0.75
Qty2 = Ctext(Int(Mqty)) & " 3/4"
Case Else
Qty2 = Ctext(Mqty)
End Select

You could add Case stmts for the 'eighths' if necessary.
Probably the 'quarters' is sufficient.

Fred Zuckerman


Great idea Fred. In fact, instead of interacting directly between the
keyboard and the table, I could have an unbound textbox that could interpret
the data entry and convert it into the appropriate numeric value before
appending to or updating the table(s) using INSERT INTO and/or UPDATE
queries, then reversing the same process to generate the reports (recipes,
etc.). All the user will see is the fraction format as text even though the
table sees the number as a double and will never see the text. I'll have to
do some reworking now but only with the data entry form(s). All the data is
already in double format. It might just be easier to write new forms and
delete the old ones.
Jul 1 '06 #7
Richard Hollenbeck wrote:
>How can a numeric field display results in fractions? If my recipe data
requires 1/2 cup of something, for example, I'm willing to punch in 0.5 in
the quantity field then select cup in the unit field, but it is more
aesthetically cool to display the number like any paper cook book would--in
plain old regular fractions. I didn't see a format to select to show
fractions. Excel has no problem displaying fractions. Any ideas?

You can enter fractions in an unbound text box and convert
them to decimals for storage through a hidden bound text
box. The unbound text box's After up date event:

Me.boundtextbox = Eval(Replace(Me.unboundtextbox," ","+"))

Create your own function with the decimal number as the
argument to convert from decimal to fractions. There are a
few of these that have been posted in the past that you can
probably find using the Google group's archives.

By adding a units arguments to the function you could even
convert 2 pints to 1 quart or whatever.
--
Marsh
Jul 1 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: John Cho | last post by:
// CHO, JOHN #include<iostream> class fracpri{ int whole; int numer; int denom;
13
by: Steve | last post by:
I am having trouble finding the answer to this question, I'm thinking the solution must be blindingly obvious, so therefore of course I cannot see it. I wish to take a fraction in DEC say .4 and...
2
by: paul gao via .NET 247 | last post by:
hi all. In my program I need to convert a double number to stringrepresentation in fraction format and vise versa. For example,convert 0.75 to string "3/4" and convert string "1/2" to 0.5.The class...
4
by: M. Uppal | last post by:
How do i convert fraction to time in c#. I need to convert 0.25 to time. Excel does this by using Selection.NumberFormat = "h:mm:ss;@" of the Cell Format function. thanks, M. Uppal
9
by: arun.hallan | last post by:
I need to derive fractions from decimals as so: 0.3333 = 1/3 0.6666 = 2/3 The decimal could also be 0.33, or 0.3333333 but the point is that it that the fraction needs to be extracted. ...
0
by: amarok | last post by:
Hello all. I'm a Software Engineering student, and I'm attempting to write a program in Java that does as follows: UML for the class: Fraction() Fraction(numerator: int) ...
4
by: Semajthewise | last post by:
Hi All For those of you that helped me with the questions on this... Thank you! I believe I have solved all the bugs in the code and wanted to post the final product. This is a set of code to solve...
3
by: Myxamatosis | last post by:
we're given an implementation file to base our class of Fraction off of. Input and output are in the format x/y, with x and y being ints, with the "/" character in the middle. so to create an...
10
by: Jason | last post by:
I'm making a program that will convert decimal inputs (in this case, in inches) and output a fractional answer. At the moment, I'm only able to output the fractional answer in three parts: A whole...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.