[AccessD] A Question of Timing

JWColby jwcolby at colbyconsulting.com
Thu Jan 4 11:05:35 CST 2007


Rocky,

I would cache these things in a collection.  Collections hold data values,
similar to an array.  The difference is that they are "single dimension"
arrays, and they can be directly indexed into using a string value.

I assume each phrase in each label is in a table

English	   Chinese
'Some Phrase'  'Some Chinese Phrase'

Read the entire language table out into a collection, place the CHINESE
phrase in the collection, KEYED ON the English phrase.
Now, as the form opens, do what you are now, only as the form opens iterate
through the controls looking for the labels etc.  Take the caption and pull
the value out of the caption, using the text from the caption as the key
into the collection.  Take the value retrieved from the collection and stuff
it into the caption.

BTW, You could also do this "one time" by switching the form into design
view after doing this and saving the form.  That saves the translated values
so that the next time the form does not need translation.

Another BTW, this would be a great place for a set of classes to do this
translation for you.  As I have said many times, I use a form class which
does EXACTLY what you are discussing.  The class scans the form looking for
controls.  Each control is processed in a big case statement where the case
selector is the control type.  Each control type then loads it's own class -
in your case labels and command buttons would each have a class.  The
control class is passed a pointer to the control currently being processed
by the scanner.  In your case, the control class would then grab the caption
from the control, look up that text in the translation collection, and take
the returned value and stuff it back into the caption property.  Once you
get these three classes functioning, you could "just drop it into" a form
and that form would "translate itself".

Classes working together to do an entire process.  The beginning of a
framework.  ;-)

John W. Colby
Colby Consulting
www.ColbyConsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Beach Access
Software
Sent: Thursday, January 04, 2007 10:50 AM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] A Question of Timing

Dear List:

 

In my manufacturing app I translate forms to various languages on the fly -
when the form opens.  The core of the translation routine looks at each
control in a form and if it's a label or command button looks up the
language record in a table (front end) and replaces the caption with the
appropriate language.  The core of the routine is:

 

        rstControls.FindFirst "fldLanguageForm = '" & argForm & "' and
fldLanguageControl = '" _

            & ctl.Name & "'"

        If rstControls.NoMatch = False Then

 

I have noticed, especially in the Chinese translation some noticeable delay
and you can see the form repaint itself the first time it opens (the second
time it seems to go much faster).

 

So I'm wondering if I put all the translations into an array when the app
starts up and search the array instead of using FindFirst on a DAO recordset
if it will be significantly faster and maybe eliminate the flicker that
occurs during translation.  The translation is called from the Open event of
the form, BTW.

 

Another approach I have considered which would be a considerable re-write,
would be to open all the forms hidden and, instead of opening them when
needed, simply make them visible.  There are about 85 forms and I don't know
if having that many forms opne at one time will cause other problems.

 

Any opinions appreciated.

 

 

MTIA

 

 

Rocky Smolin

Beach Access Software

858-259-4334

www.e-z-mrp.com

 

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list