Frank,
It sounds like your table structure contains the following fields:
Language
FormLabel
label1Caption
label2Caption
label3Caption
This is clunky (looks like a spreadsheet, and requires an extra column in
your table structure for each label. I strongly recommend you go with a
structure similar to what I provided (FormName, Language, CtrlName,
CtrlProperty, CtrlValue). The advantage of this is that you can determine
which property to change (caption, tooltiptext, or something else.
You could use a separate table for each form, but having a single table
makes more sense. You could create and populate this table with a
normalizing query that looks something like:
SELECT "bukuangkby" as [FormName], [Language],
"Form" as [CtrlName], "Caption" as [CtrlProperty],
[Column1] as CtrlValue
FROM [bukuangkby_label]
UNION ALL
SELECT "bukuangkby" as [FormName], [Language],
"NamaAnggota_label" as [CtrlName],
"Caption" as [CtrlProperty], [Column2] as CtrlValue
FROM [bukuangkby_label]
UNION ALL
SELECT "bukuangkby" as [FormName], [Language],
"nextlabel" as [CtrlName],
"Caption" as [CtrlProperty], [Column3] as CtrlValue
FROM [bukuangkby_label]
Once you have this query working, you can save it and make a make table
query to actually create your tbl_ControlProperties. Then do this for each
of the other form tables, and append them to your tbl_ControlProperties.
Finally, you go into that form, and add rows for the controls that you want
to give tooltiptext property.
The alternative is to create a table, similar to the one you have now that
is [bukuangkby_tooltips], where you have a language field, and a field for
each of the controls that has a tool tip. Then you just replicate the code
you have now, and instead of setting the Caption property, you set the
tooltiptext property.
I prefer my method, because it does it all in a single pass, contains a
single table (rather than one or two for each form), and has a table
structure that is easy to understand. Anyone looking at your tables a year
from now might have difficulty understanding what you are doing, but my
structure is much easier to decipher.
--
HTH
Dale
email address is invalid
Please reply to newsgroup only.
Frank Situmorang said:
Thanks Dale for your explanantion.
My apporoach is creating a table for the individual form and for each source
control label table I have them in many languages. I have tested it and it
works. But this is for caption of the constrol source's label. I forget that
for some source control propery I made a messgae on the control tip text
property.
My question is how should I make again for the control tips text a table?
and have the VBA as below? Can it work if I make the VBA:
Me.Form.Caption = .Fields(1)
Me.NamaAnggota_label.Control Tips Text = .Fields(2)
Something like that?
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim s As String
On Error GoTo Err_Form_Open
Set db = DBEngine(0)(0)
s = Nz(DFirst("Language", "tblDefaults"), "English")
s = "SELECT * FROM [bukuangkby_label] WHERE Language = '" & _
s & "';"
' Debug.Print s ' for testing only
Set rst = db.OpenRecordset(s, dbOpenForwardOnly)
With rst
If Not .EOF Then
Me.Form.Caption = .Fields(1)
Me.NamaAnggota_label.Caption = .Fields(2)
)
End If
.Close
End With
Set rst = Nothing
Set db = Nothing
Exit_Form_Open:
Exit Sub
--
H. Frank Situmorang
Dale Fye said:
Frank,
You could add a table to your database that contains fields (FormName,
Language, CtrlName, CtrlProperty("Caption", "ControlTipText"), CtrlValue).
Then when the user changes the language they want to use, you could run some
code that loops through each of the forms (opening each form in design view,
hidden), gets the list of control names, properties, and values, for that
form, and updates the control properties. Then save and close the form.
This is untested, but It you should get the idea.
Public Sub LanguageControls()
Dim frm As Form, intForm As Integer
Dim ctrl As Control
Dim strSQL As String, rs As DAO.Recordset
For intForm = 0 To CurrentProject.AllForms.Count - 1
DoCmd.OpenForm CurrentProject.AllForms.Item(intForm).Name, acDesign
Set frm = Forms(0)
strSQL = "SELECT * FROM tbl_LanguageConversion " _
& "WHERE [FormName] = '" & frm.Name & "' " _
& " AND [Language] = 'French'"
Set rs = CurrentDb.OpenRecordset(strSQL, , dbFailOnError)
While Not rs.EOF
set ctrl = frm.Controls(rs("CtrlName"))
ctrl.Properties(rs("CtrlProperty")) = rs("CtrlValue")
rs.MoveNext
Wend
rs.Close
Set rs = Nothing
DoCmd.Close acForm, frm.Name, acSaveYes
Next
End Sub
One issue with using this for captions is that if the new caption is longer
than the old, and the label width is not wide enough, then you could cutoff
some text. you might want to consider adding a line like:
if ctrl.controltype = acLabel then ctrl.sizetofit
--
HTH
Dale
email address is invalid
Please reply to newsgroup only.
Frank Situmorang said:
Hello,
My Switchboard menu items takes the text from menutiems table.
Since I want to make the menu items according to the language of the
country. I want to insert the menu text in local as beside the the English
column. My question is how can we say in the menu text item of the form ithat
it will take the text from the local column?
The Ooher alternative is to replace the English with the local language
text, but it is not practical.
Thanks for any idea provided.