Transaction No field in a Card File
  • Dyna
    Posts: 9
    Joined: Wed Feb 22, 2006 5:30 pm
    Contact:

    Transaction No field in a Card File

    by Dyna » Thu May 17, 2007 2:46 pm

    Is there any way to have an auto incrementing field in a card file whenever a new record is added.
    Would prefer the field to be alphanumeric like RA0001. If not a numeric field is fine. Could it then start with any number rather than starting with 00001.
    Thanks
  • COBS Tech Support
    Posts: 678
    Joined: Fri Sep 09, 2005 8:23 am

    by COBS Tech Support » Wed May 23, 2007 12:31 pm

    Auto-incrementing fields are not standard in CAPITAL but can be simulated.

    For a numeric field, assuming the card file TESTCARD, and an auto-incrementing field in it called Autoinc1, then place this in your screen script:

    Code: Select all

    If Mode = 12
       If IsEmpty(TESTCARD->Autoinc1)
          Declare nNumber Type Numeric
          nNumber := Val(ReadINI("MyCardFile", "AutoInc1", PathData() + "User", "0")) + 1
          WriteINI("MyCardFile", "AutoInc1", NTrim(nNumber), PathData() + "User")
          TESTCARD->Autoinc1 := nNumber
       Endif
    Endif


    The above assumes that the field Autoinc1 is numeric and also sufficiently large that it will never overflow (contain a number larger than the size of the field).

    For an alpha-numeric field the principle is similar, except the field is character type. Use the CBS TranInc() function to increment the transaction number. E.g.,

    Code: Select all

    Declare cTranNo Type Character
    cTranNo := TranInc(ReadINI("MyCardFile", "AutoInc1", PathData() + "User", "0"))
    WriteINI("MyCardFile", "AutoInc1", cTranNo, PathData() + "User")
    TESTCARD->Autoinc1 := cTranNo
    Last edited by COBS Tech Support on Tue Jan 10, 2012 6:53 pm, edited 1 time in total.
  • Dyna
    Posts: 9
    Joined: Wed Feb 22, 2006 5:30 pm
    Contact:

    by Dyna » Wed May 30, 2007 3:15 pm

    The script simply puts 1 in the autoinc1 field of every record that I add to the Card file. I would like the field to increment every time a new record is added, so it is pretty much like a record number.
  • COBS Tech Support
    Posts: 678
    Joined: Fri Sep 09, 2005 8:23 am

    by COBS Tech Support » Wed May 30, 2007 3:25 pm

    I'm sorry but the purpose of this forum is not to provide a free technical consulting/programming service, but rather to provide general guidance to knowledgeable users.

    If you're unable to understand the concepts explained here and diagnose and correct problems based on the concepts illustrated, please contact support@capitaloffice.com.au via email and they will put you in touch with a consultant who will do what you require in prepackaged form, for a fee.

Who is online

Users browsing this forum: No registered users and 1 guest