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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validating A PageFrame (New Rec) Before Allowing User To Continue 2

Status
Not open for further replies.

drosenkranz

Programmer
Sep 13, 2000
360
US
Hello,

I have a form with a PageFrame control that has four pages in it. When a user creates a new client record, there is a procedure which validates the user's entries into about a dozen fields on this first page of the pageframe. Whenever a user leaves the first page (with "Next Page" or "Save") , this validation procedure is run before the user is allowed to activate the next page or save their client info. If it does not pass the validationn criteria, the user receives a message and the focus is placed on the field that requires attention on this first page..

I have &quot;hot keys&quot; on all of the PageFrame's Page Tabs (captions) that allow the user to change pages with an <Alt> key and the letter on the tab. In the case:

1) Where should I place the code to run my validation code for the first page if the user leaves the first page with a &quot; hot key &quot;?

2) How would I stop the first page from deactivating in the case when a user uses a &quot;hot-key&quot; to leave the first page (if there was an exception during my validation code that required the user's attention) and retain the first page on the screen until they fix it?

Thanks,

Dave

The 2nd mouse gets the cheese.
 
1) I'd put the validation code (or a call to the validation code) in the Deactivate event.

2) Use NODEFAULT to keep from leaving the page if the data doesn't pass the test:

IF THISFORM.myValidationroutine() = .T.
RETURN
ELSE
*** error message
NODEFAULT
ENDIF
 
Hi Dave,

The code suggested by jimstarr is what I will do.

But beware that the PageFroames deactivate event will not fire if the pageframe control is skipped and for example the user presses the close button of the form. In such cases the validation will not take place. So it is better that the forms close event takes care of the validation rule.

SO I would suggest craete a method .. say myValidation at the form level.
Then in the Deactivate event.. put the code..
IF ThisForm.myValidation
DODEFAULT
ELSE
NODEFAULT
ENDIF

Then when the editing starts, diable the forms close button and diable any exit button until the record is validated. Make sure the Save button or cancel buitton then enables these back.

:)

ramani :)
(Subramanian.G)
 
Hello,

If the data passes my validation code criteria, I would simply allow the Deactivate to occur and the next page to Activate.

IF ThisForm.myValidation
DODEFAULT && No Code - Allow Page1 to deactivate.
ELSE
NODEFAULT && Put user back on Page1
ENDIF

How would I actually stop the current page (Page1) from &quot;deactivating&quot; and prohibit the next page (Page2) from &quot;activating&quot; (if the data doesn't pass the validation code) ?

Thanks,

Dave

The 2nd mouse gets the cheese.
 
Dave, I have no answer to your question but ...
I feel your programming problems began when you removed your autographed picture of Jerry Garcia from your wall.. Your inspiration has gone. You would never ask questions like this. Please hang him back up. <g>

-dpboss-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top