Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to perform record - level validation on table buffer
Message
From
06/12/2001 12:46:12
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00590634
Message ID:
00590652
Views:
28
This message has been marked as the solution to the initial question of the thread.
Hi Nadya.

>> I have a form with a grid and textboxes. I can navigate using navigation buttons or by moving directly in a grid. If user left some textboxes unfilled, I want to stay on this record and don't allow to move to another record. I don't want to touch navigation button class, if it could be avoided. <<

Add 2 custom properties to your grid class: nRec2Validate and lValidatingRow. Add a template method to the grid class called ValidateCurrentRow: code to go in the instance.

This code in BeforeRowColChange:
WITH This
  IF .lValidatingRow
    NODEFAULT
  ELSE    
    .nRec2Validate = RECNO(.RecordSource)
  ENDIF
ENDWITH
This code in AfterRowColChange:
LOCAL lnRec2GoTo
WITH This
  *** If there is no record to validate, exit stage left
  IF .nRec2Validate = 0
    RETURN
  ENDIF

  *** Save the current record number in case we have changed rows
  lnRec2GoTo = RECNO( .RecordSource )

  *** Check to see if the row has changed
  IF .nRec2Validate # lnRec2GoTo
    *** We are validating the row we are attempting to leave...set the flag
    .lValidatingRow = .T.
    *** Return to the record we just left
    GOTO .nRec2Validate IN ( .RecordSource )
    *** If it checks out, let the user move to the new row
    IF .ValidateCurrentRow()
      GOTO lnRec2GoTo IN ( .RecordSource )
      .RefreshControls()
    ENDIF
    *** Finished with validation...reset flag
    .lValidatingRow = .F.
  ENDIF
ENDWITH
RefreshControls is a template method that my base class grid has. I use it to refresh dependent controls on the form.

HTH
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform