@ארי אמר בשינוי שפת תוכנה:
עריכה, איך אפשר לכתוב תנאי כזה?
הנה הקוד של @clickone , בשינויים קלים (והזחה )
Public Function ControlExistsInForm(frm As Form, ctrlName As String) As Boolean
On Error Resume Next
ControlExistsInForm = Not frm.Controls(ctrlName) Is Nothing
On Error GoTo 0
End Function
Private Sub Form_Load()
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("SELECT * FROM LangTable WHERE FormName='" & Me.Name & "'")
While Not rs.EOF
If ControlExistsInForm(Me, rs!ControlName) Then
If Me(rs!ControlName).ControlType = acLabel Then
Me(rs!ControlName).Caption = rs(CurrentLanguageName & "Caption")
Else
Me(rs!ControlName).Value = rs(CurrentLanguageName & "Caption")
End If
rs.MoveNext
End If
Wend
End Sub
הקוד הזה הוא יותר מהיר מלולאה על כל הפקדים בטופס?
כן, כי הוא בודק רק את הפקדים שבטבלת התרגום.