On 15 Oct 2003 09:52:17 -0700,
de**@simsy.ch (J?rg Keller) wrote:
Any advice would highly be appreciated!
Hello, I've done this recently and it's working very nice.
I have set up a table 'tblVertaling' with two fields.
- Number
- Text
I've had reserved 1000 numbers for each language used (you could
reserve more if necessary, but 1000 is already much).
for instance 1-1000 = Dutch, 1001 to 2000 = English ...
The table has been filled in like this:
1 Annuleren
1001 Cancel
2001 cancel in other language
and so on
I've declared a public variable
Public lnglanguage As Long
You should set this variable for instance by opening your app. In my
example for dutch this would be 0, and for english this would be 1000.
In the onopen event of forms, reports (I've only used it for reports)
I put code like this:
************************************************** ***************
Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf ctl Is Label Then
If ctl.Tag <> "" And Not IsNull(ctl.Tag) Then
ctl.Caption = LoadString(ctl.Tag + lnglanguage) 'so eg 1 +
1000 is number 1001 out the table
End If
End If
Next ctl
************************************************** ***************
With the loadstring I call this procedure that resides in a module
pasted below.
Notice that I put the number of the translation required in the
tagfield of every object.
eg. a label that says 'Hello There!' (and has number 2 in the table
with translations) has in the tag the number (2) referencing the one
in the table with translations.
************************************************** ***************
Function LoadString(lngNumber As Long) As String
On Error GoTo HandleErrors
Dim strLoadString As String
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
Set db = CurrentDb
strSQL = "SELECT tblvertaling.* FROM tblvertaling WHERE
tblVertaling.number = " & lngNumber & ";"
Set rst = db.OpenRecordset(strSQL, dbOpenSnapshot)
With rst
If .RecordCount <> 0 Then
.MoveFirst
strLoadString = !Text
End If
End With
exithere:
On Error Resume Next
rst.Close
db.Close
Set rst = Nothing
Set db = Nothing
LoadString = strLoadString
Exit Function
HandleErrors:
MsgBox "basVertaling - LoadString:" & vbNewLine & Err.Number & " "
& Err.Description
Resume exithere
End Function
************************************************** ***************
Hopes this clear. One could always point me at bad code, or better
ways of handling this.
regards,
--
bebelino