• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 4.  Developing and Distributing ... > Find out What Language Version of Ac...

4.5. Find out What Language Version of Access Is Installed

4.5.1. Problem

You distribute your applications in several countries, and your users have different internationalized versions of Access 2002 installed. You'd like your applications to be able to make decisions based on the installed version of Access. How can you find out which language version of Access is currently running?

4.5.2. Solution

In older versions of Access, you had to use an API call to get this information. However, starting with Access 2000, it is possible to retrieve language information using the Microsoft Office Object Library. This solution demonstrates how you can gather the language information you need.

Load and run the form frmLanguage in 04-05.MDB. As it loads, it calls the necessary functions to determine the currently running language version of Access. Figure 4-10 shows the form after it's been loaded into a retail U.S. English version of Access.

Figure 4-10. frmLanguage indicates the language version of Access that's running

To include this functionality in your own applications, follow these steps:

  1. Import the module basFileLanguage from 04-05.MDB into your own application. This module includes constants representing the seven most commonly used languages and their related intrinsic constants and values.

  2. Declare a long integer variable, lngLanguage. When your application starts up, make a call to acbAccessLanguage, which will return a number representing the current running language version of Access. You can assign this return value to the lngLanguage variable, as follows:

    lngLanguage = acbAccessLanguage(  )

    You can then pass that variable to procedures in your application that make decisions based on the current language version of Access.

In the example application, the language ID is stored in an option group, which will work only if you are supporting a known, limited set of languages. The example also includes code that detects the version of Access in use and whether it is a runtime version.

4.5.3. Discussion

Retrieving language information requires setting a reference to the Microsoft Office Object Library. You can then refer to the Application object's LanguageSettings property to retrieve the language being used. Each language has its own LanguageID property, which is an integer value. These language IDs are represented by enumerated constants. When you set a reference to the Microsoft Office Object Library, you can see a complete list of constants by examining the msoLanguageID enumeration, as shown in Figure 4-11.

Figure 4-11. Each language value has a corresponding constant

The call to acbAccessLanguage requires a simple variable:

lngRetval = acb_apiGetLanguage(  )

Or you can use a control, as we have in the example:

Me.grpLanguage = acbAccessLanguage(  )

The function returns a single value, which tells you which language version the function found. Table 4-1 lists only a few of the Windows languages and the ID values associated with them, along with the corresponding constants. You can see a complete list by using the Object Browser, as shown in Figure 4-11.

Table 4-1. Windows languages and ID values
Language Constant ID
American English msoLanguageIDEnglishUS 1033
French msoLanguageIDFrench 1036
German msoLanguageIDGerman 1031
Italian msoLanguageIDItalian 1040
Russian msoLanguageIDRussian 1049
Spanish msoLanguageIDSpanish 1034
Portuguese msoLanguageIDPortuguese 2070
Swedish msoLanguageIDSwedish 1053
Zulu msoLanguageIDZulu 1077

The simple function in basFileLanguage, acbAccessLanguage, returns only the national language ID number (from Table 4-1) for the installed version of Access:

Function acbAccessLanguage(  ) As Long
    acbAccessLanguage = _
End Function

Once you know the ID for the national language, you can make choices in your application. For example, as shown in the next two solutions, you can modify labels on forms and reports and modify the error messages that you display.

The example form also uses two functions from basAccessInfo in 04-05.MDB, acbGetVersion and acbIsRuntime. Both are quite simple, comprising only calls to the built-in SysCmd function. The first, acbGetVersion, returns the version number of the currently running copy of Access. The second, acbIsRuntime, returns True if your application is running in the runtime version of Access or False if it's in the retail version. You may find these functions useful if your application needs to react differently to different environments.

Public Function acbGetVersion(  ) As String
   ' Retrieve the Access version for places
   ' that can't use symbolic constants.

   acbGetVersion = SysCmd(acSysCmdAccessVer)
End Function

Public Function acbIsRuntime(  ) As Boolean
   ' Use SysCmd(  ) to gather the information.

   acbIsRuntime = SysCmd(acSysCmdRuntime)
End Function

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint