[AccessD] Using the clsCacheState

jwcolby jwcolby at colbyconsulting.com
Wed Dec 22 22:11:35 CST 2010


Just a caution, if you are placing code and tables out into a library (as I do) you need to be 
careful to use CodeDb and CurrentDb correctly so that you open the table in the right place. 
Generally if you are going to monitor a value you will do so in the CurrentDb so that the value is 
picked out of a (linked?) table in the application.  This allows the code to work for many different 
applications using the same physical copy of the library.

John W. Colby
www.ColbyConsulting.com

On 12/22/2010 10:24 PM, Jim Dettman wrote:
>
>    Only thing you need to watch out for with holding a recordset open is your
> working towards the 2048 tableID limit.  Start using this a lot and you
> could reach the limit faster then you might think.
>
>   And BTW, you really need to start publishing this stuff!
>
> Jim.
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby
> Sent: Wednesday, December 22, 2010 07:14 PM
> To: Access Developers discussion and problem solving
> Subject: Re: [AccessD] Using the clsCacheState
>
> Oh and I forgot, to test monitoring changes created by another user, do the
> below, and then open the
> container with the table in another session, and modify the value there,
> directly in the table.
> Watch that it does indeed show up in the class instance.
>
> John W. Colby
> www.ColbyConsulting.com
>
> On 12/22/2010 6:03 PM, jwcolby wrote:
>> Place the following in a module
>>
>> Option Compare Database
>> Option Explicit
>>
>> Private cCacheState As clsCacheState
>>
>> Public Function cCState() As clsCacheState
>>        If cCacheState Is Nothing Then
>>            Dim db As DAO.Database
>>            Set db = CurrentDb
>>            Set cCacheState = New clsCacheState
>>
>>            'The table and field names below must be changed to match your
> table names
>>            cCacheState.mInit db, "usystblPLSSysVars", "PLSSV_Name",
> "PLSSV_Val", "PLSDataUpdate"
>>        End If
>>        Set cCState = cCacheState
>> End Function
>>
>> Create a table named usystblPLSSysVars with field names PLSSV_Name and
> PLSSV_Val.  Create a record
>> with the values PLSDataUpdate in the PLSSV_Name and anything at all in
> PLSSV_Val.
>>
>> You can actually create a table of any name with fields named whatever you
> want, but the above works
>> with the module above so if you create your own table you will need to
> modify the test code above.
>>
>> Now in the debug window do the following things
>>
>> cCState.pRefreshed = now()
>> ccstate.pModified = now()
>> ?ccstate.pRefreshed
>> 12/22/2010 4:50:48 PM
>> ?ccstate.pModified
>> 12/22/2010 4:51:01 PM
>> ?ccstate.pRefreshNeeded
>> False
>> True
>>
>> You can step through and watch the class perform.  You can add the class
> anywhere that you need to
>> monitor a value modified by another user.
>>



More information about the AccessD mailing list