LPARAMETERS nColIndex llChangingRow =.F. WITH this IF mdown() lnBottom = .top+.headerheight+.relativerow * .rowheight lnTop = lnBottom - this.rowheight lnMouseRowPos = mrow(wontop(),3) lnMouseColPos = mcol(wontop(),3) llChangingRow = !(between(lnMouseRowPos,lnTop, lnBottom) ; and between(lnMouseColPos,.left,.left+.width)) * Is click on a different row ELSE llChangingRow = inlist(lastkey(),24,5,18,3) * Was lastkey() in Up,down, pgup,pgdown ENDIF ENDWITH *!* * Check for missing SIZE or QUANTITY fields IF llChangingRow = .T. DO CASE CASE EMPTY(This.grcDescript.grcboDescript.value) NODEFAULT CASE This.grcQty.grtxtQty.value = 0 && Has the user forgotten to enter the quantity? MESSAGEBOX("Please enter the desired quantity.",MB_ICONEXCLAMATION + MB_OK,"Required information missing.") THIS.grcQty.grtxtQty.SETFOCUS() nodefault CASE empty(This.grcSize.grCboSize.value) && Has the user forgotten to enter the size? IF NOT EMPTY(ggproducts.sizes) && do sizes exist for this item? MESSAGEBOX("Please enter the desired Size.",MB_ICONEXCLAMATION + MB_OK,"Required information missing.") THIS.grcSize.grCboSize.SETFOCUS() nodefault ENDIF OTHERWISE ACTIVATE SCREEN ? 'llChangingRow = ', llChangingRow, 'Value = ',This.grcDescript.grcboDescript.value,; 'Qty = ',This.grcQty.grtxtQty.value, 'Size = ',This.grcSize.grCboSize.value ENDCASE ENDIF RETURNIn the AfterRowColChange event, I have:
LPARAMETERS nColIndex LOCAL lnNewRec, lnOrderID, lnItem, lnOldArea * When new row added, fill in Order ID and Line_ID in OrderItems table IF orderitems.order_id <1 && New item? lnNewRec = recno('orderitems') * (NewID function creates orderitem.key value) lnOrderID= orders.order_id REPLACE orderitems.order_id WITH lnOrderID && fill in order ID lnItem=1 && Find last item # LOCATE FOR orderitems.order_id=lnOrderID .AND. orderitems.line_id=lnItem DO WHILE FOUND() lnItem=lnItem+1 CONTINUE ENDDO GOTO (lnNewRec) REPLACE orderitems.line_id WITH lnItem && Insert item number in new record ENDIF THISFORM.REFRESH() ACTIVATE SCREEN && Debugging - display values ? 'Record = ', recno(), 'Value = ',This.grcDescript.grcboDescript.value,; 'Qty = ',This.grcQty.grtxtQty.value, 'Size = ',This.grcSize.grCboSize.value