Change Number to Arabic and back

A

Abdul

Hi,

I have set my regional settings to English(UK). Is it possible to
change the number format to Arabic(Saudi Arabia) and back to
English(UK) by code?

So that I will run a report using either of the format.

Thanks

Abdul
 
G

GeoffG

I think the solution to your problem will be very challenging. I can't offer
complete help because I've never done this before. The following is only a
suggestion. (I hope someone else might know an easier way.)

You will need to base your report on a query that makes a call to a Windows
API function, which will format the numbers according to the appropriate
locale. Here is a list of possible API functions:

GetNumberFormat()
This API function formats a number according to the specified locale.

GetCurrencyFormat()
This API function formats a currency value according to the specified
locale.

GetDateFormat()
This API function formats a date value according to the specified locale.

GetTimeFormat()
This API function formats a time according to the specified locale.

EnumSystemLocales()
This API function obtains a list of all the locales installed or supported
on a system

This is where it gets tricky. Here is an example of how to declare the
GetNumberFormat() API function:

Declare Function GetNumberFormat Lib "kernel32" Alias "GetNumberFormatA"
(ByVal Locale As Long, ByVal dwFlags As Long, ByVal lpValue As String,
lpFormat As NUMBERFMT, ByVal lpNumberStr As String, ByVal cchNumber As Long)
As Long

As you see, it's complex. You'll have to declare the function like this in a
VBA module. You'll then need to call the function by passing to it the
arguments it requires. API functions are very fussy. Get an argument wrong
and your system is liable to crash.

In order to ensure that the arguments are perfect, I think it would be best
if you wrote your own function, which you call from the query. Your function
can, in turn, call the API function, ensuring that the arguments are
perfect.

One of my text books gives more information on what all the arguments mean.
If you think this is an approach you want to pursue, I can post the
additional information later. Please say which API function you want to use.

On a less complex matter, you could use the Report_Open event to ask the
user which language the report should use and store their answer in a
variable. You could then pass the English (UK) or Arabic (Saudi Arabia)
locale ID to the API function from your own function.

I'm afraid I don't know how any of this would affect your report - for
example, if you have a grouped report which calculates group totals. My
guess is everything should be OK, but I don't know for sure.

You may get a better answer if you post your problem to a newsgroup dealing
with API functions. You'll need to keep in mind that you will be calling the
API function from VBA, not from the C language. A lot of information about
API functions is aimed at C programmers. You'll also find information on
the Microsoft website.

As you no doubt know already, the following webpage gives details of the
various formats for Arabic (Saudi Arabia):

http://www.microsoft.com/globaldev/nlsweb/default.mspx?submitted=0401&OS=Windows Vista

Geoff.
 

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