Tags: access, application, caption, database, forms, gettheir, internationalize, iterate, iteration, labels, mde, microsoft, mysql, oracle, property, reports, sql

iteration through Caption property of all labels

On Database » Microsoft Access

10,880 words with 4 Comments; publish: Tue, 03 Jun 2008 22:57:00 GMT; (250261.72, « »)

Hello.

I want to internationalize my. mde application forms and reports.

Is it possible to iterate through all labels in all forms an reports, get

their Caption property values, put them in some local JET table and then use

it for other language translations?

I thought to add translations as columns to that local table, so that during

start-up, my application cheks which language is currently selected and then

dynamically set Caption property value for every label in every form and

report...

What do you think about this approach? Is there any similar approach already

implemented? Some examples? Some advices?

How to iterate through all reports and forms and get all Caption property

value for all labels?

Thank you in advance,

Zlatko

All Comments

Leave a comment...

  • 4 Comments
    • comments inline.

      "tatamata" <zlatko.matic1.ms-access.todaysummary.com.sb.t-com.hr> wrote in message

      news:ef3eem$1816$1.ms-access.todaysummary.com.fegnews.vip.hr...

      > Hello.

      > I want to internationalize my. mde application forms and reports.

      > Is it possible to iterate through all labels in all forms an reports, get

      > their Caption property values, put them in some local JET table and then

      use

      > it for other language translations?

      yes, it should be possible.

      > I thought to add translations as columns to that local table, so that

      during

      > start-up, my application cheks which language is currently selected and

      then

      > dynamically set Caption property value for every label in every form and

      > report...

      by "columns", you mean *fields* in the table. creating a field for each

      language, as

      tblCaptions

      ObjectType

      ObjectName

      LabelName

      English

      Spanish

      German

      <etc, etc, etc>

      is NOT normalized table structure. instead, suggest the following two-tables

      structure, as

      tblLabels

      LabelID (autonumber, primary key)

      ObjectType

      ObjectName

      LabelName

      tblLabelCaptions

      LabelID (foreign key from tblLabels)

      Language

      (use these two fields as a combination primary key, or add an autonumber

      field to serve as the primary key, if you like.)

      LabelText

      > What do you think about this approach? Is there any similar approach

      already

      > implemented? Some examples? Some advices?

      > How to iterate through all reports and forms and get all Caption property

      > value for all labels?

      to populate the table with form and report label names, try the following

      code, as

      Public Sub getForms()

      Dim dbs As Object, obj As Object, ctl As Control, frm As Form

      Set dbs = Application.CurrentProject

      For Each obj In dbs.AllForms

      DoCmd.OpenForm obj.Name

      Set frm = Forms(obj.Name)

      For Each ctl In frm.Controls

      If TypeOf ctl Is Label Then

      CurrentDb.Execute "INSERT INTO tblLabels " _

      & "( ObjectType, ObjectName, LabelName ) " _

      & "SELECT 'Form', '" & frm.Name & "', '" _

      & ctl.Name & "'", dbFailOnError

      End If

      Next ctl

      DoCmd.Close acForm, obj.Name, acSaveNo

      Next obj

      End Sub

      Public Sub GetReports()

      Dim dbs As Object, obj As Object, ctl As Control, rpt As Report

      Set dbs = Application.CurrentProject

      For Each obj In dbs.AllReports

      DoCmd.OpenReport obj.Name, acViewPreview

      Set rpt = Reports(obj.Name)

      For Each ctl In rpt.Controls

      If TypeOf ctl Is Label Then

      CurrentDb.Execute "INSERT INTO tblLabels " _

      & "( ObjectType, ObjectName, LabelName ) " _

      & "SELECT 'Report', '" & rpt.Name & "', '" _

      & ctl.Name & "'", dbFailOnError

      End If

      Next ctl

      DoCmd.Close acReport, obj.Name, acSaveNo

      Next obj

      End Sub

      the two procedures are nearly identical, except for the form vs report

      references. i was too lazy to come up with a more elegant way of doing it,

      in one procedure. ;)

      to iterate through the controls in a single object and find the labels, try

      the code below. you can use it for setting label captions on form Load

      events, and report Open (probably) events.

      Public Function SetCaption()

      Dim ctl As Control

      With CodeContextObject

      For Each ctl In .Controls

      If TypeOf ctl Is Label Then

      <put here the code to change the label's Caption property>

      End If

      Next ctl

      End With

      End Function

      paste the function into a public module, so it can be called from anywhere

      in the database.

      hth

      #1; Tue, 03 Jun 2008 22:59:00 GMT
    • Tina, thank you for your answer and detailed instructions

      Best regards,

      Zlatko

      "tina" <nospam.ms-access.todaysummary.com.address.com> je napisao u poruci interesnoj

      grupi:QzdRg.98653$QM6.53348.ms-access.todaysummary.com.bgtnsc05-news.ops.worldnet.att.net...

      > comments inline.

      > "tatamata" <zlatko.matic1.ms-access.todaysummary.com.sb.t-com.hr> wrote in message

      > news:ef3eem$1816$1.ms-access.todaysummary.com.fegnews.vip.hr...

      > use

      > yes, it should be possible.

      > during

      > then

      > by "columns", you mean *fields* in the table. creating a field for each

      > language, as

      > tblCaptions

      > ObjectType

      > ObjectName

      > LabelName

      > English

      > Spanish

      > German

      > <etc, etc, etc>

      > is NOT normalized table structure. instead, suggest the following

      > two-tables

      > structure, as

      > tblLabels

      > LabelID (autonumber, primary key)

      > ObjectType

      > ObjectName

      > LabelName

      > tblLabelCaptions

      > LabelID (foreign key from tblLabels)

      > Language

      > (use these two fields as a combination primary key, or add an autonumber

      > field to serve as the primary key, if you like.)

      > LabelText

      > already

      > to populate the table with form and report label names, try the following

      > code, as

      > Public Sub getForms()

      > Dim dbs As Object, obj As Object, ctl As Control, frm As Form

      > Set dbs = Application.CurrentProject

      > For Each obj In dbs.AllForms

      > DoCmd.OpenForm obj.Name

      > Set frm = Forms(obj.Name)

      > For Each ctl In frm.Controls

      > If TypeOf ctl Is Label Then

      > CurrentDb.Execute "INSERT INTO tblLabels " _

      > & "( ObjectType, ObjectName, LabelName ) " _

      > & "SELECT 'Form', '" & frm.Name & "', '" _

      > & ctl.Name & "'", dbFailOnError

      > End If

      > Next ctl

      > DoCmd.Close acForm, obj.Name, acSaveNo

      > Next obj

      > End Sub

      > Public Sub GetReports()

      > Dim dbs As Object, obj As Object, ctl As Control, rpt As Report

      > Set dbs = Application.CurrentProject

      > For Each obj In dbs.AllReports

      > DoCmd.OpenReport obj.Name, acViewPreview

      > Set rpt = Reports(obj.Name)

      > For Each ctl In rpt.Controls

      > If TypeOf ctl Is Label Then

      > CurrentDb.Execute "INSERT INTO tblLabels " _

      > & "( ObjectType, ObjectName, LabelName ) " _

      > & "SELECT 'Report', '" & rpt.Name & "', '" _

      > & ctl.Name & "'", dbFailOnError

      > End If

      > Next ctl

      > DoCmd.Close acReport, obj.Name, acSaveNo

      > Next obj

      > End Sub

      > the two procedures are nearly identical, except for the form vs report

      > references. i was too lazy to come up with a more elegant way of doing it,

      > in one procedure. ;)

      > to iterate through the controls in a single object and find the labels,

      > try

      > the code below. you can use it for setting label captions on form Load

      > events, and report Open (probably) events.

      > Public Function SetCaption()

      > Dim ctl As Control

      > With CodeContextObject

      > For Each ctl In .Controls

      > If TypeOf ctl Is Label Then

      > <put here the code to change the label's Caption property>

      > End If

      > Next ctl

      > End With

      > End Function

      > paste the function into a public module, so it can be called from anywhere

      > in the database.

      > hth

      >

      #2; Tue, 03 Jun 2008 23:00:00 GMT
    • you're welcome

      "tatamata" <zlatko.matic1.ms-access.todaysummary.com.sb.t-com.hr> wrote in message

      news:ef407u$of4$1.ms-access.todaysummary.com.fegnews.vip.hr...[vbcol=seagreen]

      > Tina, thank you for your answer and detailed instructions

      > Best regards,

      > Zlatko

      > "tina" <nospam.ms-access.todaysummary.com.address.com> je napisao u poruci interesnoj

      > grupi:QzdRg.98653$QM6.53348.ms-access.todaysummary.com.bgtnsc05-news.ops.worldnet.att.net...

      get[vbcol=seagreen]

      then[vbcol=seagreen]

      and[vbcol=seagreen]

      property[vbcol=seagreen]

      following[vbcol=seagreen]

      it,[vbcol=seagreen]

      property>[vbcol=seagreen]

      anywhere

      >

      #3; Tue, 03 Jun 2008 23:01:00 GMT
    • Hi Zlatko,

      To add to Tina's answer, you might want to check out the August, 2006 issue

      of Access Advisor magazine:

      Localize Microsoft Access Applications On-The-Fly

      Accommodate multiple languages using a table-driven, front-end solution.

      http://zones.advisor.com/doc/18129

      I believe Advisor sells single issues of this publication.

      Tom Wickerath

      Microsoft Access MVP

      http://www.access.qbuilt.com/html/ex...tributors.html

      http://www.access.qbuilt.com/html/search.html

      __________________________________________

      "tatamata" wrote:

      > Hello.

      > I want to internationalize my. mde application forms and reports.

      > Is it possible to iterate through all labels in all forms an reports, get

      > their Caption property values, put them in some local JET table and then use

      > it for other language translations?

      > I thought to add translations as columns to that local table, so that during

      > start-up, my application cheks which language is currently selected and then

      > dynamically set Caption property value for every label in every form and

      > report...

      > What do you think about this approach? Is there any similar approach already

      > implemented? Some examples? Some advices?

      > How to iterate through all reports and forms and get all Caption property

      > value for all labels?

      > Thank you in advance,

      > Zlatko

      #4; Tue, 03 Jun 2008 23:02:00 GMT