Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Number Resequence Problem...?
Message
From
28/09/2001 07:01:31
 
 
To
26/09/2001 09:26:37
N. Lea
Nic Cross Enterprises
Valencia, California, United States
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00560912
Message ID:
00561837
Views:
20
Hi N.Lea,

Your problem seems to be answered by Will Jones. Nevertheless i am providing u small help-line which can reduce your efforts.
I am supposing that you have already declared nNewPrintOrder as a PUBLIC Variable.

This line of code
	nNewPrintOrder = ROUND(VAL(SPACE(5)),0) 


can be re-written as -
  	nNewPrintOrder = 0 


The rest of the code is as -


SET DELETED ON && Deleted Records Will be Ignored.
calias() = ALIAS()
coldorder = ORDER(ALIAS())
SET ORDER TO

noldvalue = plfile.printorder
nrecordno = RECNO(ALIAS())

DO FORM gl_pnl_neworder


SELECT IIF(calias#ALIAS(),calias, ALIAS()) && SETTING THE CORRECT ALIAS FOR PROCESSING

GOTO nrecordno
REPLACE plfile.printorder WITH nnewprintorder

IF lcontinue = .T.
IF nnewprintorder >= noldvalue
nresetprintorder = 1
SCAN FOR printorder <= nnewprintorder
IF RECNO()<>nrecordno
REPLACE printorder WITH nresetprintorder
nresetprintorder = nresetprintorder + 1
ENDIF
ENDSCAN
ELSE
nresetprintorder = nnewprintorder + 1
SCAN FOR printorder >= nnewprintorder
IF RECNO() <> nrecordno
REPLACE printorder WITH nresetprintorder
nresetprintorder = nresetprintorder + 1
ENDIF
ENDSCAN
ENDIF

THISFORM.grdfinancialchart.REFRESH()
ENDIF

SELECT &calias && Setting the old alias as the current alias
THISFORM.mplrecalculate()
GO TOP


N.Lea try using the above code, i am sure u will not get a double digit repeated figure in your re-ordering. Let me know did this help you?


Sanjay.
(shams201@yahoo.com)
(sanjaypatel@india.com)

solutions written Are neatly DONE



>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!
Sanjay Dhiraj Patel

MCSE, MCDBA

Net2Biz (Thailand)
Previous
Reply
Map
View

Click here to load this message in the networking platform