Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditionally CLOSE Update procedure

Status
Not open for further replies.

TinLegs

Programmer
Jan 14, 2003
100
NZ
Greetings all,

I am a Clarion Legacy man learning ABC. I would like to conditionally disallow a user from adding any more records to a file (ie. if the program is in demo mode only).
I can trap this at the Browse level fine but would like to add a secondary trap at the 'Update' level also.

Q. What ABC code should I use and at what embed point to abort the 'Update' procedure conditionally without changing the records in the file in any way and safely return to the Browse.

I have tried various methods and embed points and I can abort the 'Update' procedure OK but have since found that a blank record is added to the file. The file has no related child or parent files.

I am using Clarion 6.1

Thank you
 
Hi!

In the Update Form ::

WindowManager.Init - after opening window
Code:
IF <ConditionForDemoMode> AND SELF.Request = InsertRecord AND RECORDS(Table) > <MaxDemoRows>
   MESSAGE('CANNOT Add more that <nn> records in Demo Mode')
   POST(EVENT:CloseWindow)
   RETURN LEVEL:Fatal
END

In the Browse Procedure ::

WindowManager.Init - last embed
Code:
IF <ConditionForDemoMode> AND RECORDS(Table) >= <MaxDemoRows>
   BrowseObject.InsertControl = False
   DISABLE(?Insert) 
END

Regards
 
Thank you ShankarJ

Your code provided is more refined than mine but even after using it I still had the same problem in that a blank record was being added to the file if I bypassed the Browse trap and used the Update trap only as a test.

I have since discovered the I had a record in the Table that I called RecordNumber with a RecordNumberKey whose Attributes were Auto Number and by removing this record and key which was not required it has solved the problem but I still find it interesting that I was still not able to abort the Update without any action been taken at all.

The Update trap will probely never be used because it is trapped at the Browse level but as the Irish say... to be sure, to be sure.

Kind Regards,
TinLegs
 
Hi,

You could change your Update Form Code to ::

Code:
IF <ConditionForDemoMode> AND SELF.Request = InsertRecord AND RECORDS(Table) > <MaxDemoRows>
   MESSAGE('CANNOT Add more that <nn> records in Demo Mode')
   Access:<Table>.CancelAutoInc()
   POST(EVENT:CloseWindow)
   RETURN LEVEL:Fatal
END

You could also add a ::
Code:
DISABLE(1, LASTFIELD())

for more MORE SURE. :)

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top