Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sharing form
Message
From
24/10/2004 14:53:55
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 5
Miscellaneous
Thread ID:
00954064
Message ID:
00954118
Views:
17
Hi David,

I agree totally. The function I sent to Mohammed earlier today, is not in use by me anymore. In stead I use the following function, which here is english-ized. It uses a specific Nummer.dbf which has only one record but many fields containing the last used values for different tasks. The function returns the next number for the given field name.
FUNCTION GetNextNumber
  LPARAMETERS lcInput
  LOCAL lcSelected, lnOutput, lcOnError
  lcSelected = SELECT(0)
  lcOnError  = ON('error')
  IF USED('nummer')
    USE IN nummer
  ENDIF
  ON ERROR DO ExclusiveRetryElseError WITH ERROR( ), MESSAGE( ), MESSAGE(1), PROGRAM( ), LINENO( )
  IF !FILE('nummer.dbf')
    IF MESSAGEBOX(lu("Warning Call technical support NOW!") + CHR(13)+CHR(10) + lu("And give the following message: GetNextNumber-Create"), 4+32+0, "TB 2004") = 6
      CREATE TABLE 'nummer' (EXISTS L)
      USE IN nummer
    ENDIF
  ENDIF

  USE nummer IN 0 EXCLUSIVE

  IF TYPE('nummer.'+ALLTRIM(lcInput)) != 'N'
    IF MESSAGEBOX(lu("Warning Call technical support NOW!") + CHR(13)+CHR(10) + lu("And give the following message: GetNextNumber-Add") + " " + lcInput, 4+32+0, "TB 2004") = 6
      ALTER TABLE 'nummer' ADD COLUMN (lcInput) N(14)
    ENDIF
  ENDIF
  IF RECCOUNT('nummer') = 0
    APPEND BLANK IN nummer
  ENDIF
  lnOutput = (nummer.&lcInput) + 1
  REPLACE (lcInput) WITH lnOutput IN nummer
  USE IN nummer

  ON ERROR &lcOnError
  FLUSH
  SELECT (lcSelected)
RETURN lnOutput

PROCEDURE ExclusiveRetryElseError
  LPARAMETERS                              mError,   MESS,       mess1,      mprog,      mlineno
  IF INLIST(mError, 108, 109, 1705)	&& Error in exclusive open
    WAIT WINDOW "Waiting for another user" TIMEOUT 0.2
    ON ERROR DO ExclusiveRetryElseError WITH ERROR( ), MESSAGE( ), MESSAGE(1), PROGRAM( ), LINENO( )
    RETRY
  ELSE
    DO m2kerror WITH mError, MESS, mess1, mprog, mlineno && My generic error handler
  ENDIF
ENDPROC
>Mohammed,
>
>This is the exact issue I was raising last week in your GO BOTTOM thread. http://www.levelextreme.com/wconnect/wc.dll?FournierTransformation~2,15,951720
>
>You need to either use autoincrementing fields or your own custom GetNextKey() function to ensure that multiple users can not create records with the same PK values.
>
>>i'll try to insert two bills at the same time via same form via two pc
>>
>>1.i creat temp.table
>>2.at my form i put a grid to insert my item via temp.table
>>3.when i finish insert items, at save command i append all things from my grid to mstr.table
>>
>>but if mybill number is =14 at my pc,
>>i can see the same number at another pc.
>>
>>how i can let every pc have another number of bill , when i open myform to add new bills
>>via 2 pc or more.
>>or if another way to do that
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform