Doug Haven't looked at MS Access for years.
AFAIK and remember, Access' Autonumber field can be equivalent to Cach� Class instance's ID, which cannot be changed or fiddled with by the user. So there may not be need to take preventive measures. Perhaps Peter Cooper can enlighten us on this. HTH Regards Sukesh Hoogan Doug Pickering <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I am fairly new to Cache and am attempting to move an access database to > cache whilst maintaining compatibility with the existing access application. > I have created a datatype to represent the access autonumber field type and > have used this to define the appropriate fields. I have then decided to > create a class to emulate the behaviour of the autonumber fields (i.e. not > allowing them to be updated on update, nor specified on insert). > The MSAccessBaseClass uses the objectgenerator to create methods which > perform the checking eliminating the need for me to manually code it > everywhere. There is an exception to this, I want to prevent ODBC calls from > being to update or insert autonumbers. > I have tried the following example syntax, but 'CodeMode = objectgenerator' > is not allowed in a trigger definition. > What I would like to know is; > a) is there anyway to use the objectgenerator on triggers? > or > b) is there another way to acheive the same result without having to create > code in each class. > > Regards, > > Doug Pickering > > Class User.MSAccessBaseClass Extends %Library.Persistent [ ProcedureBlock ] > { > ... > /// This trigger will prevent the autonumber field from being updated. > Trigger preventAutonumberUpdate [ Event = UPDATE ,CodeMode = > objectgenerator] > { > For i = 1:1:%compiledclass.Properties.Count() > { > if %compiledclass.Properties.GetAt(i).Type = "User.MSAccessAutoNumber" > { > Set cls = %compiledclass.Name > Set prop = %compiledclass.Properties.GetAt(i).Name > Do %code.WriteLine(" if {" _ prop _ "*N} '= {" _ prop _ "*O} ") Do > %code.WriteLine(" { ") Do %code.WriteLine(" Set $ECODE="",ZAttempted to > change Autonumber field on update,""") > Do %code.WriteLine(" }") > } > } > } > ... > } > >
