Option Compare Database
Const c_defLang As String = "Rus" 'язык по умолчанию
Public Sub SelectLanguage(frm As Form)
Dim ctrl As control
Dim rst As ADODB.Recordset
Dim strLanguage As String
strLanguage = CurrentLaguage
Set rst = New ADODB.Recordset
rst.Open "SELECT Control, " & strLanguage & " FROM tblTranslation " _
, CurrentProject.Connection, adOpenKeyset, adLockReadOnly
rst.MoveFirst
On Error Resume Next
For Each ctrl In frm
rst.Find "Control = '" & ctrl.name & "'"
If rst.BOF Or rst.EOF Then
Else
ctrl.Caption = rst(strLanguage)
End If
rst.MoveFirst
Next ctrl
End Sub
Public Function CurrentLaguage() As String
If Not CurrentProject.AllForms!frmStartup.IsLoaded Then
CurrentLaguage = c_defLang
Else
CurrentLaguage = Forms!frmStartup!cbxLanguage
End If
End Function
Public Function langMsgBox(strPrompt As String, Optional Buttons As VbMsgBoxStyle = vbOKOnly, Optional strTitle As String = "", Optional strHelpFile, Optional strContext) As VbMsgBoxResult
Dim strLanguage As String
strLanguage = CurrentLaguage
langMsgBox = MsgBox(Nz(DLookup(strLanguage, "tblTranslation", "[control]= '" & strPrompt & "'"), ""), Buttons, Nz(DLookup(strLanguage, "tblTranslation", "[control]= '" & strTitle & "'"), ""), strHelpFile, strContext)
End Function
|