5 Replies Latest reply on Apr 11, 2014 7:11 AM by philmodjunk

    Generate Serial Number Button?

    FionaWilson

      Title

      Generate Serial Number Button?

      Post

      Hi,

      I need to know if its possible to generate a new serial number usinig a button, so that only records that require a new number get one.  

      I have a contact management database that manages our Museum's entire contact list. This includes our membership database.

      Each record has a serial number assigned on creation but I would also like the ability to assign a Membership Card number to members. Not everyone in our database is a member, so I don't want it to generate a card number on record creation, only when they join as a member.

      I would like to have a button that generates a membership card number when its clicked.

      Is this possible?

        • 1. Re: Generate Serial Number Button?
          Kays

          u could set a script by that button, that runs on a global field (Gfield) that u initialize with 0 or 1 ..., the script will be :

          Set Field(Table::field; GlobalTable::GField)      the field u wanna insert the serial number in

          set Field (GlobalTable::GField; GlobalTable::GField + 1)

          K|Z

           

          • 2. Re: Generate Serial Number Button?
            Abhaya

            Yes you can do it by script

            it is better to ist set a default value and it look  nice

            like 66601/cardm

            • 3. Re: Generate Serial Number Button?
              philmodjunk

              There can be a possible danger with this set field script. If two or more users perform this script at the same time, you can get identical numbers. Furthermore, in a networked database, your global field will revert to it's original value when you reopen the database the next time.

              Here's a "bullet proof" method for generating serial numbers on demand when the database is such that two or more users might need to perform this script at the same time:

              Define a second table, CardNumber, with just two fields:
              MemberID (Number field)
              CardNumber (Auto-entered Serial Number)

              Relate them to your contact table like this:

              Contacts::MemberID = CardNumber::MemberID

              Enable "Allow Creation of Records via this relationship" for CardNumber.

              Now this script step will generate a unique card number for each member when you click a button to perform a script. Should you accidentally click the button twice, no change in the number will take place:

              Set Field [CardNumber::MemberID ; Contacts::MemberID ]

              Just place the CardNumber::CardNumber field on your contacts layout and you'll see a serial number appear in it the first time you click the button to assign a card number to that contact record.

               

              • 4. Re: Generate Serial Number Button?
                tkosiba

                     Phil:

                     I followed (duplicated) your above method. 

                     Several problems:

                     1) When I trigger the script button, it does not populate the "cardmember" table field. 

                     2) Even with "allow Creations of Records" activated, that field is not populated either.

                     3) If I add a record in the cardnumber table, it will auto populate a cardmember number.

                     4) Your last line: Just place the cardnumber::cardnumber field on the contacts page (I don't understand, is the creating a field and how do you insert that cardnumber::cardnumber?).

                     Sorry I'm new to this game, but trying to learn "key functions" that can be of benefit. 

                      

                • 5. Re: Generate Serial Number Button?
                  philmodjunk

                       Your several problems indicate that you haven't set up the needed relationships, fields and field options correctly, but I can't tell from your post what was not done correctly.

                       To add cardnumber::Cardnumber to your layout:

                       Enter layout mode

                       Drag and drop from the field tool to add a new field to your layout.

                       Select "Cardnumber" from the drop down list at the top of the specify fields dialog that this action opens.

                       Then click the Cardnumber field to select that field.

                       PS. I stumbled onto your post by accident. Due to a limitation in how this forum works threads more than 3 months old will not appear in recent items when you post a comment to them. This thread is several years old. When post to such older threads, I recommend starting a new thread and including a link to the original thread in it to improve the chances that someone will see your post.