[AccessD] Find First in an Array?

Drew Wutka DWUTKA at Marlow.com
Thu Feb 19 12:53:16 CST 2009


Of course.  You have to look at the controlling entity.  Even though the
forms have the controls, each form has separate controls, to try and
find a control in a recordset is going to require 'looking' for that
record.  If you can just pull up all the records based on the form, you
now have all the controls, it's just listed in the order that the
recordset pulls them up in, not in the order the form has.

Of course, the irony is, you are still using a collection.  You are
using the controls collection, which is indexed by the controls
name.....  you just didn't program the controls collection. ;)

Drew

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin
at Beach Access Software
Sent: Thursday, February 19, 2009 11:57 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Find First in an Array?

Dang.  I think you're right.  Gotta try that.  You think it'll be faster
than SEEK? 


Rocky Smolin
Beach Access Software
858-259-4334
www.e-z-mrp.com
www.bchacc.com
 
 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Drew Wutka
Sent: Thursday, February 19, 2009 9:33 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Find First in an Array?

Hmmmm, actually, the way you have this set up, you could do this just
fine
without an array or collection.

Instead of this:

For Each ctl In frm
    rstControls.FindFirst "fldLanguageForm = '" & argForm & "' and
fldLanguageControl = '" _
        & ctl.Name & "'"

Do this:

strSQL="SELECT fldLanguageControl, fldLanguage" & strLanguageToTranslate
& "
FROM tblYourTableName WHERE fldLanguageForm=""" & me.Name & """"
set rs=New Recordset
rs.open strsql,currentproject.connection, adopenkeyset,adlockreadonly if
rs.eof=false then rs.movefirst do until rs.eof=true
	me(rs.fields(0).value).Caption=rs.fields(1).value
Loop
Rs.close
Set rs=nothing

That way you are pulling the recordset up....and just running through it
once...instead of trying to find every record based on the control.

Drew

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin
at
Beach Access Software
Sent: Thursday, February 19, 2009 12:57 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Find First in an Array?

John:

The table layout is:

fldLanguageID             Autonumber
fldLanguageForm           Text Name of the form that the control is on
fldLanguageControl        Text Name of the control 
fldLanguageControlType    Text Not Used
fldLanguageEnglish        Text
fldLanguageChineseComplex Text
fldLanguageChineseSimple  Text
fldLanguageSpanish        Text
fldLanguageFrench         Text	

In the translate routine I use:

Set frm = Forms(argForm)
For Each ctl In frm
    rstControls.FindFirst "fldLanguageForm = '" & argForm & "' and
fldLanguageControl = '" _
        & ctl.Name & "'"

Where argForm is the form name passed to the function.  So I think I
might
get a big boost in response time by indexing fldLanguageForm and
fldLanguageControl.

There are only about 2500 records in the table so I'm thinking that the
whole recordset is probably in memory anyway.


Rocky Smolin
Beach Access Software
858-259-4334
www.e-z-mrp.com
www.bchacc.com
 
 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Wednesday, February 18, 2009 5:46 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Find First in an Array?

Does this imply a table structure of:

TR_ID		Auto
TR_CtlName	Text
TR_L1		text (or memo?) for language 1
TR_L2		text (or memo?) for language 2
Etc

I would suggest that you add a form (or container) field.  A control
name is
unique on a form, however it could be the same on different forms but
have a
different language string.  By having a form field you could pull
subsets of
records based on the form name, then use the control name (now
guaranteed to
be unique), then obtain the language string.

It appears from your email however that you already have this stuff set
up,
so you might be resistant to modifying how it works.

If this is all just one big table with control names guaranteed to be
unique
then you could just stash it in one big collection.  There is a problem
however which is that classes get pretty slow as they get large.  If you
get
up past 10,000 strings (I don't know the exact point) it would bog back
down.  If you broke it down into controls on a form, then you would
ensure
that the total strings in any given collection is pretty small.

Again I would build a class for all the code and the collection to load
one
form.  then a supervisor class to hold instances of this form class
keyed on
form name.

John W. Colby
www.ColbyConsulting.com


Rocky Smolin at Beach Access Software wrote:
> Max:
> 
> That would work except the table driven approach is so much more
easier.
> Easy to add a language (got French and Spanish now in addition to 
> traditional and simplified Chinese), too, or make a change to a
translation.
> To add a language I just add a column for that language to the Control

> and Messages tables and send them to the translator.  Add that 
> language to the language selector combo on the Preferences form, and 
> walla! Another language.
> 
> 
> Rocky Smolin
> Beach Access Software
> 858-259-4334
> www.e-z-mrp.com
> www.bchacc.com

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

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com 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.


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

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
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