Jim Dettman
jimdettman at verizon.net
Thu Jan 4 10:36:26 CST 2007
I'd follow gustav's advice and use seek. I also wanted to add that you can
use seek on a remote teable, but you must open the remote database first.
See code below.
Jim.
Function SetUserPreferences(lngUserID, strObjectName, strValue As String) As
Integer
Dim wrk As Workspace
Dim dbCurrent As Database
Dim dbRemote As Database
Dim tdfAttached As TableDef
Dim strPath As String
Dim rst1 As Recordset
Dim rst1Field As Field
'
' First, get the path to the MDB for the attached table.
'
Set wrk = DBEngine.Workspaces(0)
Set dbCurrent = wrk.Databases(0)
Set tdfAttached = dbCurrent.TableDefs("tblUserPreferences")
strPath = tdfAttached.Connect
strPath = right$(strPath, Len(strPath) - InStr(strPath, "="))
Set dbRemote = wrk.OpenDatabase(strPath, False, False)
'
' Find the preference for the given user.
'
Set rst1 = dbRemote.OpenRecordset("tblUserPreferences", DB_OPEN_TABLE)
rst1.index = "PrimaryKey"
rst1.Seek "=", lngUserID, strObjectName
If rst1.NoMatch Then
rst1.AddNew
rst1![UserId] = lngUserID
rst1![ObjectName] = strObjectName
Else
rst1.Edit
End If
rst1![Value] = strValue
rst1.Update
rst1.Close
Set rst1 = Nothing
dbRemote.Close
Set dbRemote = Nothing
Set tdfAttached = Nothing
Set dbCurrent = Nothing
Set wrk = Nothing
End Function
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: Thursday, January 04, 2007 11:08 AM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] A Question of Timing
Hi Rocky
You could use DAO and the Seek method on this local table if it is indexed
properly.
Seek is extremely fast but the syntax is a bit weird.
/gustav
>>> bchacc at san.rr.com 04-01-2007 16:50 >>>
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