none
Making a MS Access 2010 database as Multi-language database RRS feed

  • Question

  • I was looking at this post on this forum about changing the language on buttons and labels

    Changing the language on Buttons and Labels

    The DBguy said: The only suggestion I have is to keep the language translations in a table and have a settings option to select the language to use. Then, in the Open event of your forms and report, you can set the labels based on the settings selected by the user.

    How do you change the in the Open event of your forms and reports, to set the labels based on the settings selected by the user? Would I have to call a function in order to do this?

    I was wondering if there is a main form which you can make the language change, how do the changes automatically update in the all of the forms and reports of the database?

    Thanks

    Tuesday, January 30, 2018 5:46 PM

Answers

  • You should still be able to get this to work.

    Each form has to be considered a form – even if used as a sub-form.

    Note that when you use a navigation form “system” in your application, then each form is in fact launched as a sub-form. And if you navigate away from that form, it is no longer loaded.

    Keep above in mind, then you for all forms (even ones launched as a sub form, or as a result of a navigation choice), then in the on-open evet of that form, you want to run your code. And ALL code MUST be forms “neutral” in the sense that none of the code uses forms!”some form name”. (Because you can’t reference sub forms – and some forms will be used as sub-forms, and the SAME form must work when launched + used as non-sub form.

    So you label set code must be like this:

    Me("some control").caption = "my caption text"

    Because of the possible use of a given form as sub form, then each and all forms in their on-open event have to run your code that sets the captions for the labels.

    And just keep in mind that you can’t use any hard coded forms! References in that code, since the form could be a sub form, and note that you can for example open the same form 20 times. (If you create a main form, you are free to drop in the SAME sub form 20 times into that form – so you always have to use “me” to reference the given instance of that form.

    Regards,

    Albert D. Kallal (Access MVP 2003-2017)

    Edmonton, Alberta Canada


    • Edited by Albert D. Kallal Thursday, February 1, 2018 6:16 PM
    • Marked as answer by wirejp Friday, February 2, 2018 2:07 AM
    Thursday, February 1, 2018 6:15 PM

All replies

  • Assuming that the desired language is specified with a control on another form, on the target forms "OnLoad" event, cycle through the target forms' controls changing labels captions depending/based upon the desired language.
    • Marked as answer by wirejp Wednesday, January 31, 2018 3:36 AM
    • Unmarked as answer by wirejp Wednesday, January 31, 2018 8:53 PM
    • Marked as answer by wirejp Wednesday, January 31, 2018 8:53 PM
    • Unmarked as answer by wirejp Thursday, February 1, 2018 9:38 AM
    Tuesday, January 30, 2018 7:47 PM
  • I would likely design a table to hold the information for a given form. You in fact likely adopt two tables with a structure something like:

    tblFormInfo

    ID

    FormName  (name of form, or report)

    HelpFile (perhaps for future use)

    Child table to above:

    tblFormControls:

    ID

    formInfo_ID

    ControlName:

    TEnglish

    TFrench

    TSpanish

    Etc.

    So you build a main form + sub form that lets you edit the above. I would also suggest you build some code to pull + grab the existing labels from a given form and populate the above with the English values for the labels (they already have the English text). Now it just a matter to enter the other languages into this form.

    Now in the forms on-open event you can pull the above information as a query (you have a record set of all the labels names you need to set. You then loop though the above child table, and set the values of the labels based on the language setting.

    I done this in the past (not with access). The great part about placing the text in a database was we entered all the English labels, and then sent the database off to someone who knew French. And then off to someone who knew Spanish etc.

    So the idea is to create a “data” structure that will hold the values for all labels for a given form. You then loop though the controls record set in the on-open event, and set the label. You of course have a “case” statement that is the language setting, and pull + set each label based on the language setting.

    You code will look something like:

    do while rstLables.EOf = false

       strCaption = rstLables(gblLanguageSettting)

       me(rstlables!ControlName).Caption = strCaption

       rstLables.MoveNext

    loop

    In above I assume a global var called gblLanguageSetting which s set to the language field name you pull the correct label text from that one record of the label(s) for the given form.

    It in fact not much code at all.

    Albert D. Kallal (Access MVP 2003-2017)

    Edmonton, Alberta Canada


    • Edited by Albert D. Kallal Tuesday, January 30, 2018 10:21 PM
    • Marked as answer by wirejp Wednesday, January 31, 2018 3:36 AM
    • Unmarked as answer by wirejp Wednesday, January 31, 2018 8:53 PM
    • Marked as answer by wirejp Wednesday, January 31, 2018 8:56 PM
    • Unmarked as answer by wirejp Wednesday, January 31, 2018 8:56 PM
    • Marked as answer by wirejp Wednesday, January 31, 2018 8:56 PM
    • Unmarked as answer by wirejp Thursday, February 1, 2018 9:38 AM
    Tuesday, January 30, 2018 10:20 PM
  • How do you change the in the Open event of your forms and reports, to set the labels based on the settings selected by the user? Would I have to call a function in order to do this?

    Hi wirejp,

    I use a meta data table, that describes how every control should behave in an application. Among others is that the field to which the control is related, and the name of the control to display. The controls are organized per Item (the entity in the table). In this systematics it is not a problem to use aliasses or translations of the field to display as label. This can be done in the Open event of the form.

    You can even change dynamical to other translations. In the meta data table is all the information to change which controls/labels to what language.

    Perhaps this all sounds a little abstract, it is all possible. But as it is not standard in Access, you have to code it by yourself.

    Give it a thought, and perhaps ...

    Imb.

    • Marked as answer by wirejp Wednesday, January 31, 2018 3:36 AM
    • Unmarked as answer by wirejp Wednesday, January 31, 2018 8:53 PM
    • Marked as answer by wirejp Wednesday, January 31, 2018 8:56 PM
    • Unmarked as answer by wirejp Thursday, February 1, 2018 9:38 AM
    Tuesday, January 30, 2018 11:03 PM
  • Thank you for all of the responses.

    If the forms will form part of a Main Navigation Form, would I have to set the open load event of the individual forms and then set the on load event of the subforms in the Main Navigation Form?

    Thanks.

    Tuesday, January 30, 2018 11:49 PM
  • Hi wirejp,

    You had asked,"If the forms will form part of a Main Navigation Form, would I have to set the open load event of the individual forms and then set the on load event of the subforms in the Main Navigation Form?"

    It is better you done this process on all the forms, when user use the database for first time.

    Then you can set the flag variable that this process was already done.

    So when ever user open the database again then Access will skip this process.

    The advantage is that you not need to process it for opened forms again and again.

    You need to develop the logic to check whether database is open for first time or not.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by wirejp Wednesday, January 31, 2018 3:35 AM
    • Unmarked as answer by wirejp Thursday, February 1, 2018 9:38 AM
    Wednesday, January 31, 2018 3:09 AM
    Moderator
  • Hello All,

    I have setup a Switch Board form which has a link to a navigation form which contains all of my forms. I managed to VBA code my Switch Board to make it Multi-Language. I started to add the labels, buttons to the tblControlCaption table from the other forms individually. I then On Load Event of the forms to link to the query with the stored Language Default. The Language on the labels/buttons in the forms change to the new foreign language. However, in the Navigation Form, there the language on the labels/buttons remain in English and did not change. Also, I noticed that if I click the link on the SwitchBoard form to access the navigational form, I get an error message that no reference exist and the form cannot be found. However, if I remove the On Load Event on the individual forms, then I do not get an error message when I click the link on the SwitchBoard form.

    • Edited by wirejp Thursday, February 1, 2018 9:40 AM
    Thursday, February 1, 2018 9:40 AM
  • You should still be able to get this to work.

    Each form has to be considered a form – even if used as a sub-form.

    Note that when you use a navigation form “system” in your application, then each form is in fact launched as a sub-form. And if you navigate away from that form, it is no longer loaded.

    Keep above in mind, then you for all forms (even ones launched as a sub form, or as a result of a navigation choice), then in the on-open evet of that form, you want to run your code. And ALL code MUST be forms “neutral” in the sense that none of the code uses forms!”some form name”. (Because you can’t reference sub forms – and some forms will be used as sub-forms, and the SAME form must work when launched + used as non-sub form.

    So you label set code must be like this:

    Me("some control").caption = "my caption text"

    Because of the possible use of a given form as sub form, then each and all forms in their on-open event have to run your code that sets the captions for the labels.

    And just keep in mind that you can’t use any hard coded forms! References in that code, since the form could be a sub form, and note that you can for example open the same form 20 times. (If you create a main form, you are free to drop in the SAME sub form 20 times into that form – so you always have to use “me” to reference the given instance of that form.

    Regards,

    Albert D. Kallal (Access MVP 2003-2017)

    Edmonton, Alberta Canada


    • Edited by Albert D. Kallal Thursday, February 1, 2018 6:16 PM
    • Marked as answer by wirejp Friday, February 2, 2018 2:07 AM
    Thursday, February 1, 2018 6:15 PM