[AccessD] Find First in an Array? - TheSolutionRevisited-NowTag is the Answer

Drew Wutka DWUTKA at Marlow.com
Tue Feb 24 18:35:19 CST 2009


LOL.  Thanks, I got it (after googling the reg key to allow .mdb's
through in Outlook...grrrrrrrr....)

(The solution for that, by the way:
http://www.annoyances.org/exec/show/article08-104
)

I took a look at it.  It's a good idea.  

The example I posted shouldn't make your head spin though William. 

First, there is a class, 'ControlLanguage'.  Then there is a module with
Function Startup(), which sets a global instance of ControlLanguage.
Then there is 12 lines of code to put behind your form:

Dim WithEvents ContrlLang As ControlLanguage
Private Sub ContrlLang_LanguageChanged()
Dim ctrl
For Each ctrl In Me.Controls
    If ContrlLang.Caption(Me.Name, ctrl.Name) <> "" Then
        ctrl.Caption = ContrlLang.Caption(Me.Name, ctrl.Name)
    End If
Next
End Sub
Private Sub Form_Load()
Set ContrlLang = CurrentControlLanguages
ContrlLang_LanguageChanged
End Sub

Which sinks the global ControlLanguage's events into the form (the Dim
WithEvents line), and then has code to set the captions when the
language changes, and then on the Onload event, it manually fires that
code, to update the form with the current 'global' language.

The code in the class module is pretty simple too.  Less then half the
number of lines then what's in the module in Max's tag example.  (Not
that less is better...but certainly it can't be that confusing!).

On the Class initialize, it initializes the collection (Captions), and
then runs through the table with all the translations, setting the key
to the translation as "FormName:ControlName:Language".

The CurrentLanguage Property triggers the 'LanguageChanged' event (so
you can read that property, but when you set it, it let's everything
(forms/reports) that is listening that the language is changed.

And the Caption property asks for the Form Name and Control name, so it
can return the correct Caption....if it doesn't find a caption , it
returns and empty string.

Whalla.  Open both frmPartMaster and frmSupplySide.  Then open Form1,
and select a language and click.  (Note, the class code does set English
as the default language....)  Notice that both forms instantly change to
the language you select.  

The code behind Form1 is simply setting:

CurrentControlLanguages.CurrentLanguage = Me.Combo1

Which is the property that triggers the event....this could be done from
anything, a stand alone form, a control on any particular form, a menu,
etc.

Is that really complicated?

Drew

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of William
Hindman
Sent: Tuesday, February 24, 2009 5:55 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Find First in an Array? -
TheSolutionRevisited-NowTag is the Answer

...ok already ...its on its way :)

William

--------------------------------------------------
From: "Drew Wutka" <DWUTKA at marlow.com>
Sent: Tuesday, February 24, 2009 6:42 PM
To: "Access Developers discussion and problem solving" 
<accessd at databaseadvisors.com>
Subject: Re: [AccessD] Find First in an Array? - The 
SolutionRevisited-NowTag is the Answer

> Well somebody send it to me!
>
> Drew
>
The information contained in this transmission is intended only for the person or entity to which it is addressed and may contain II-VI Proprietary and/or II-VI Business Sensitive material. If you are not the intended recipient, please contact the sender immediately and destroy the material in its entirety, whether electronic or hard copy. You are notified that any review, retransmission, copying, disclosure, dissemination, or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited.





More information about the AccessD mailing list