Number Printed in Reverse Order

C

clk

Hello. I have an Access report where the last three digits of the
order amount print on my report footer with some random numbers as a
code. I would like to reverse this number. Is there any way to print
a number in reverse order?

So for example: Order Total $1350
Now....my code generates a random number 756.350

I would like it to generate the random number 756.053 (but put the 350
(last three digits of order total) in reverse order).

Any help would be appreciated.

Thank you.
 
K

Klatuu

You can create a function that will put the numbers in the order you want
and use the function as the control source of the control where you wish to
display it.

The function could be something like this:

Public Function CodeString(CodeNumber As Double) As String
CodeString = Format(CodeNumber, "000.000")
CodeString = Left(CodeString, 4) & Mid(CodeString, 7, 1) & _
Mid(CodeString, 6, 1) & Mid(CodeString, 5, 1)

End Function

Then you can call it from the control source of the text box:

=CodeString(MyNumber)

I would even consider putting the code to generate the random number in the
function.
 
F

fredg

Hello. I have an Access report where the last three digits of the
order amount print on my report footer with some random numbers as a
code. I would like to reverse this number. Is there any way to print
a number in reverse order?

So for example: Order Total $1350
Now....my code generates a random number 756.350

I would like it to generate the random number 756.053 (but put the 350
(last three digits of order total) in reverse order).

Any help would be appreciated.

Thank you.

First generate your random number, i.e. 750.123

Copy and paste the below function into a module.

Public Function NewNum(RandomNum as string) as String
Dim LastThree as string
Dim Reversed as string

LastThree = Right(RandomNum,3)
Reversed = Right(LastThree,1) & Mid(LastThree,2,1) &
Left(LastThree,1)

NewNum = Left(RandomNum, Len(RandomNum)-3) & Reversed

End Function


Then, call the above function using an unbound control in your report:

= NewNum(RandomNumber)
 
S

Stuart McCall

clk said:
Hello. I have an Access report where the last three digits of the
order amount print on my report footer with some random numbers as a
code. I would like to reverse this number. Is there any way to print
a number in reverse order?

So for example: Order Total $1350
Now....my code generates a random number 756.350

I would like it to generate the random number 756.053 (but put the 350
(last three digits of order total) in reverse order).

Any help would be appreciated.

Thank you.

Paste this function into a standard module:

Public Function RndFormat(RndNum)
Dim p As Long
p = Instrrev(RndNum, ".")
RndFormat = Left(RndNum, p) & StrReverse(Right(RndNum, p + 1))
End Function

Then call it from a form or report:

=RndFormat(MyRandomNumber)
 
G

Graham Mandeno

I think your question has already been answered magnificently three times,
so I am not offering another solution.

But please, I am intrigued...

If this is a random number, then why on earth do you care about the order of
the last three digits?
 
C

clk

I think your question has already been answered magnificently three times,
so I am not offering another solution.

But please, I am intrigued...

If this is a random number, then why on earth do you care about the orderof
the last three digits?

--
Graham Mandeno [Access MVP]
Auckland, New Zealand




Hello.  I have an Access report where the last three digits of the
order amount print on my report footer with some random numbers as a
code.  I would like to reverse this number.  Is there any way to print
a number in reverse order?
So for example:  Order Total $1350
Now....my code generates a random number 756.350
I would like it to generate the random number 756.053 (but put the 350
(last three digits of order total) in reverse order).
Any help would be appreciated.
Thank you.- Hide quoted text -

- Show quoted text -

Thank you to everyone for the help on this issue. To answer the last
post on "why" do this....it was a request by my client. They use it
as some checking mechanism on their end.

Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top