M
Michel
I am developing a front-end that has to be bilingual. I set up a
tblLanguage with the following field
FormName
ControlName
ControlType
DateUpdated
English
French
The following code works fine for all forms with no subform. The
problem I would like to know how to resolve regards subform. I cannot
make this work for the labels on the subform. I added ***** where I get
a VB error.
Any suggestion on how to resolve this would be very appreciated.
Thanks
Michel
Private Sub langSetControls(recLang As Recordset, _
strLang As String, strFormName As String)
Dim FrmF As Form
Dim ctlc As Control
Dim strControlName As String
Dim intControlType As Integer
**********Set FrmF = Forms(strFormName)*********************
With recLang
.Seek "=", strFormName, strFormName
'add or update the form in the language table
If .NoMatch Or IsNull(.Fields(strLang)) Then
FrmF.Caption = ""
Else
FrmF.Caption = .Fields(strLang)
End If
'now loop through the controls
For Each ctlc In FrmF.Controls
'we are only interested in the controls
'with a caption property
intControlType = ctlc.ControlType
If ControlHasCaption(intControlType) = True Then
'find the control in the language table
strControlName = ctlc.Name
.Seek "=", strFormName, strControlName
'add or update the control in the language table
If .NoMatch Or IsNull(.Fields(strLang)) Then
ctlc.Caption = ""
Else
ctlc.Caption = .Fields(strLang)
End If
End If
Next
End With
End Sub
Private Function ControlHasCaption(intCtlType As Integer) As Boolean
Select Case intCtlType
Case acCommandButton, acLabel, acToggleButton
ControlHasCaption = True
Case Else
ControlHasCaption = False
End Select
End Function
Private Function ControlTypeName(intCtlType As Integer) As String
Select Case intCtlType
Case acLabel
ControlTypeName = "Label"
Case acCommandButton
ControlTypeName = "Command button"
Case acToggleButton
ControlTypeName = "Toggle button"
End Select
End Function
Public Sub OpenFormLanguage(bolExtract As Boolean, strLang As String,
strFormName As String)
Dim db As DAO.Database
Dim recLang As DAO.Recordset
'Open the database and language recordset
Set db = CurrentDb()
Set recLang = db.OpenRecordset(wcsLANGUAGETABLE)
recLang.Index = "PrimaryKey"
If bolExtract Then
LangExtractControls recLang, strLang, strFormName
Else
langSetControls recLang, strLang, strFormName
End If
'close up
recLang.Close
End Sub
tblLanguage with the following field
FormName
ControlName
ControlType
DateUpdated
English
French
The following code works fine for all forms with no subform. The
problem I would like to know how to resolve regards subform. I cannot
make this work for the labels on the subform. I added ***** where I get
a VB error.
Any suggestion on how to resolve this would be very appreciated.
Thanks
Michel
Private Sub langSetControls(recLang As Recordset, _
strLang As String, strFormName As String)
Dim FrmF As Form
Dim ctlc As Control
Dim strControlName As String
Dim intControlType As Integer
**********Set FrmF = Forms(strFormName)*********************
With recLang
.Seek "=", strFormName, strFormName
'add or update the form in the language table
If .NoMatch Or IsNull(.Fields(strLang)) Then
FrmF.Caption = ""
Else
FrmF.Caption = .Fields(strLang)
End If
'now loop through the controls
For Each ctlc In FrmF.Controls
'we are only interested in the controls
'with a caption property
intControlType = ctlc.ControlType
If ControlHasCaption(intControlType) = True Then
'find the control in the language table
strControlName = ctlc.Name
.Seek "=", strFormName, strControlName
'add or update the control in the language table
If .NoMatch Or IsNull(.Fields(strLang)) Then
ctlc.Caption = ""
Else
ctlc.Caption = .Fields(strLang)
End If
End If
Next
End With
End Sub
Private Function ControlHasCaption(intCtlType As Integer) As Boolean
Select Case intCtlType
Case acCommandButton, acLabel, acToggleButton
ControlHasCaption = True
Case Else
ControlHasCaption = False
End Select
End Function
Private Function ControlTypeName(intCtlType As Integer) As String
Select Case intCtlType
Case acLabel
ControlTypeName = "Label"
Case acCommandButton
ControlTypeName = "Command button"
Case acToggleButton
ControlTypeName = "Toggle button"
End Select
End Function
Public Sub OpenFormLanguage(bolExtract As Boolean, strLang As String,
strFormName As String)
Dim db As DAO.Database
Dim recLang As DAO.Recordset
'Open the database and language recordset
Set db = CurrentDb()
Set recLang = db.OpenRecordset(wcsLANGUAGETABLE)
recLang.Index = "PrimaryKey"
If bolExtract Then
LangExtractControls recLang, strLang, strFormName
Else
langSetControls recLang, strLang, strFormName
End If
'close up
recLang.Close
End Sub