Re: DataType Conversion Speed



Then divide by zero to conver to percent.
I'm sure you mean divide by 100

"Allen Browne" wrote:

> I assume:
> - discount2 and discount3 are Number type fields,
> - the value 10 means 10%,
> - if neither field contains a value, the discount is 0,
> - if either field contains a value, that's the discount,
> - if both fields contain a value, the sum is the discount.
>
> Try entering something like this in a fresh column of the Field row in
> query design:
> CDbl(Nz([discount2],0) + Nz([discount3],0) / 100)
>
> The Nz() converts null to zero.
> It then sums the two.
> Then divide by zero to conver to percent.
> Then expllicitly typecast to double to prevent the problem described in:
> Calculated fields misinterpreted
> at:
> http://allenbrowne.com/ser-45.html
>
> Without the user-defined function calls and converting to string and back
> again, that should fix both the performance issues and the
> misinterterpretation of the results. To display the result as a percent, set
> the Format property of your text box to:
> Percent
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia.
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "John" <John@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:14B59626-54CD-49F7-9F93-CE04BCE8424A@xxxxxxxxxxxxxxxx
> > Hi all,
> >
> > I have a problem that needs help. I have a report that needs to show
> > some discounts but these discount are not always contain a value. So,
> > they
> > are concatenated using the formula like this:
> >
> > .. IIf([discount2]>0,Str([discount2]) & "% ","") &
> > IIf([discount3]>0,Str([discount3]) & "% ","")..
> >
> > However, user found that if the discount starts with "0" such as 0.25%,
> > the print out will be ".25%" with the starting 0 missed.
> >
> > So, I have written a function in the module. It accepts a currency
> > variable, converts the input to string and check if the first 2 character
> > are
> > " .". If so, add a "0" in front of it.
> >
> > When I run the report again. I found it run very very slow.
> >
> > Consequently, I want to ask if there are any alternatives instead of
> > writting a function to do this?
> >
> > If a function is really required, how can I speed up the report
> > printing?
> >
> > The module written by me is as follows:
> >
> > Function CurrencyToString(inCurrency As Currency) As String
> >
> > CurrencyToString = Str(inCurrency)
> > If Left(CurrencyToString, 2) = " ." Then
> > CurrencyToString = " 0" & LTrim(CurrencyToString)
> > End If
> >
> > End Function
> >
> >
> > Thanks for your attention.
> >
> > Rgs,
> > John
>
>
>
.



Relevant Pages

  • Re: DataType Conversion Speed
    ... > Then divide by zero to conver to percent. ... >> - if either field contains a value, that's the discount, ... >> Then divide by zero to conver to percent. ...
    (microsoft.public.access.modulesdaovba)
  • Re: fft2 and ifft2 outputs
    ... Dave Robinson ... ./ is this element by element divide? ... whereas correlation requires the conjugation of the second vector. ... The reason that you are getting a divide by zero error is because you ...
    (comp.soft-sys.matlab)
  • Re: How many mathematicians ...
    ... be divided by 7 before multiplying by 6. ... Who is trying to divide h by 7? ... No division by zero. ... gets to zero even if Bonehead wishes it so. ...
    (sci.physics.relativity)
  • RE: #Num! division with IIf statements
    ... you will get a divide by zero error by specifyin 0 and the False ... In reality it's not divided by zero, these are nulls divided by nulls. ... particular date-range that's where I get the #Num! ...
    (microsoft.public.access.reports)
  • Re: Boasting
    ... When you defend yourself from his trolls by pointing out with a wink ... and a grin that you could divide his IQ into yours and obtain an ... Zero is an integer, fuckwit. ... Most normal people are boring to begin with but after you peel away ...
    (misc.writing)