Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Number Resequence Problem...?
Message
From
26/09/2001 09:26:37
N. Lea
Nic Cross Enterprises
Valencia, California, United States
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
Number Resequence Problem...?
Miscellaneous
Thread ID:
00560912
Message ID:
00560912
Views:
62
Good morning all!! I have a situation with a renumbering sequence problem. My code seems to be right, and it works are far as an open table through the command window. As I have it, my table called plfile is order by a field called PrintOrder N(3). There are currently 31 records in this table. On the form, this table is accessed through a grid called grdFinancialChart. The code that executes this renumbering sequence is located in the right-click event. The problem that I am having is that when trying to change the printorder from current value of 12 to the new value of 6, somewhere along the line (usually when the value is 2 digits), the system skips a record and thus a value is duplicated in the printorder field. 1,2,3,4,5,6,7,8,9,10,10,11,12,13,14...etc

Here is the code that is executed in the right click of the grid column for printorder. The form that is being executed in the code is a ghost form with only a textbox and button which has a controlsource of a variable which is carried out through the code:

WITH THISFORM	
lContinue = .F.

&& STORES INFO FROM DATABASE
nNewPrintOrder = ROUND(VAL(SPACE(5)),0)
nOldValue = plfile.printorder
nRecordNo = RECNO()
MESSAGEBOX("RECORD#" + ' '+ STR(RECNO()),0)

DO FORM gl_pnl_neworder

GOTO nRecordNo
REPLACE plfile.printorder WITH nNewPrintOrder

IF lContinue = .T.
**OLD # 4 and NEW is 7
IF nNewPrintOrder >= nOldValue
nResetPrintOrder = 1
SCAN FOR printorder <= nNewPrintOrder AND RECNO () <>nRecordNo
REPLACE printorder WITH nResetPrintOrder
nResetPrintOrder = nResetPrintOrder + 1
ENDSCAN
ELSE
MESSAGEBOX("RECORD#" + ' '+ STR(RECNO()),0)
nResetPrintOrder = nNewPrintOrder + 1
SCAN FOR printorder >= nNewPrintOrder AND RECNO()<>nRecordNo
REPLACE printorder WITH nResetPrintOrder
nResetPrintOrder = nResetPrintOrder + 1
ENDSCAN
ENDIF

.grdFinancialChart.Refresh()
ENDIF

THISFORM.mPLRecalculate()
GO TOP
ENDWITH


Thanks for any help or assistance with this problem that is haunting me!
Next
Reply
Map
View

Click here to load this message in the networking platform