I'm new to VFP9. I'm actually a VB programmer who drew the short straw and got stuck supporting a VFP9 program.
I have a data grid that contains several columns. The main ones involved in this question are UnitNo and Inactive (which is a 1 char flag). I need to do some validation to make sure that each UnitNo is entered no more than 2 times. One with an Inactive flag set to "Y" and one with "N".
I've got my cursor that gets declared on page load (crea curs tmpgridu (unitno C(8),inactive C(1)). After the cursor is declared an index is set (inde on inactive+unitno tag unitno addi).
The cursor is loaded and used as the recordsource for the data grid. On the validate routine for the Unitno field I run a query against the cursor (SELECT inactive FROM (thisform.pageframe1.page2.grdunits.RecordSource) WHERE unitno = This.Value INTO ARRAY aTemp) and if 2 records are returned I assume that there's already a record with "Y" and "N", and if one is returned I handle it accordingly. The UnitNo field is validating perfectly.
I have 4 records in my grid currently. The UnitNo values are ("TEST", "TEST 1", "TEST 2", and "1")
I tried using the same query method when validating the Inactive field. but I get junk returned. (SELECT inactive FROM (thisform.pageframe1.page2.grdunits.RecordSource) WHERE ALLTRIM(unitno) = UPPER(ALLTRIM(tmpgridu.unitno)) INTO ARRAY aTemp) When I tab through the Inactive field on the "TEST" record, it returns 3 records. The Array contains "TEST", "TEST 1" and "TEST 2".
The only difference between these two situations is that In the UnitNo Validation routine, I'm querying based on this.value and in the INactive validation routine, I'm quering based on tmpgridu.unitno from the cursor.
I'm sorry for being long winded but I wanted to give enough information so that some VFP guru can show me where I'm going wrong.
Thanks in advance for your help.
I have a data grid that contains several columns. The main ones involved in this question are UnitNo and Inactive (which is a 1 char flag). I need to do some validation to make sure that each UnitNo is entered no more than 2 times. One with an Inactive flag set to "Y" and one with "N".
I've got my cursor that gets declared on page load (crea curs tmpgridu (unitno C(8),inactive C(1)). After the cursor is declared an index is set (inde on inactive+unitno tag unitno addi).
The cursor is loaded and used as the recordsource for the data grid. On the validate routine for the Unitno field I run a query against the cursor (SELECT inactive FROM (thisform.pageframe1.page2.grdunits.RecordSource) WHERE unitno = This.Value INTO ARRAY aTemp) and if 2 records are returned I assume that there's already a record with "Y" and "N", and if one is returned I handle it accordingly. The UnitNo field is validating perfectly.
I have 4 records in my grid currently. The UnitNo values are ("TEST", "TEST 1", "TEST 2", and "1")
I tried using the same query method when validating the Inactive field. but I get junk returned. (SELECT inactive FROM (thisform.pageframe1.page2.grdunits.RecordSource) WHERE ALLTRIM(unitno) = UPPER(ALLTRIM(tmpgridu.unitno)) INTO ARRAY aTemp) When I tab through the Inactive field on the "TEST" record, it returns 3 records. The Array contains "TEST", "TEST 1" and "TEST 2".
The only difference between these two situations is that In the UnitNo Validation routine, I'm querying based on this.value and in the INactive validation routine, I'm quering based on tmpgridu.unitno from the cursor.
I'm sorry for being long winded but I wanted to give enough information so that some VFP guru can show me where I'm going wrong.
Thanks in advance for your help.