[AccessD] Using the clsCacheState

jwcolby jwcolby at colbyconsulting.com
Wed Dec 22 18:13:55 CST 2010


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