label strategy question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to change the labels on my input controls programmatically which
I realize I can do with Me.Caption = ...

But I need to change all the labels on a form from one language to another.
I can store all the label texts in a table with a column for the target
language. But I'm not seeing how to load those. If I use a DLookUp (for each
Me.Caption), that's a ton of DLookups for one form and a huge performance hit.

How have others done this?
 
you could set up a table with three columns, as

tblLabels
LabelName
Language
CaptionText

set LabelName and Language as a combination primary key. you can store
captions for multiple languages here, and the combo primary key will prevent
entering the same language twice for the same caption. so records in the
table would look like

Label1 English Good morning
Label1 Spanish Buenos dias
Label2 English Good night
Label2 Spanish Buenos noches

then you can loop through a recordset in the form's VBA module to set the
captions, as

Dim rst As DAO.Recordset, strSQL As String

strSQL = "SELECT LabelName, CaptionText FROM tblLabels " _
"WHERE Language = 'Spanish'"

Set rst = CurrentDb.OpenRecordset(strSQL)
rst.MoveFirst
Do
Me(rst("LabelName")).Caption = rst("CaptionText")
rst.MoveNext
Loop Until rst.EOF

rst.Close
Set rst = Nothing

the only thing you need to decide is how to change the language name
specified in the SQL statement's WHERE clause.

hth
 
smk23 said:
I would like to change the labels on my input controls programmatically which
I realize I can do with Me.Caption = ...

But I need to change all the labels on a form from one language to another.
I can store all the label texts in a table with a column for the target
language. But I'm not seeing how to load those. If I use a DLookUp (for each
Me.Caption), that's a ton of DLookups for one form and a huge performance hit.

How have others done this?


Open a recordset for the language stuff, then loop through
its records setting the captions.
 
Back
Top