So herein lies the answer. Create a method (lets say OBJEXIST()). The method aquires a control count on the form. Then using the number of controls, creates a loop with a DO CASE structure in its interior. The case structure tests for the BASECLASS of the controls. IF a CASE of command button exists, test its SUBSTR(object.Name,7) for "cmdNEXT". Then if such a button exists disable it. With this process encapsulation is not violated, the commandbutton maintains maximum independence, it may also be placed in a container with other objects, and this enables maximum reutilization of code. The code here is of course invoked from an appropriate test for EOF().
For lncount = 1 to ThisForm.ControlCount
DO CASE
CASE ThisForm.Controls(lncount).BaseClass = "CommandButton"
ThisForm.Controls(lncount).Enabled = IIF(SubStr(ThisForm.Controls(lncount).Name,7)= "cmdNEXT",.F.,.T.)
CASE .....
EndCase
Of course this.code can and should be extended to other objects, and it can be extended to check additional containers in a form.
Terry Rooks
Software Systems Architect
Microsoft Certified Solution Developer.Net
If at first you don't succeed, then skydiving definitely isn't for you.