Many databases applications require that each record contain a unique number that can be used to identify the record. Common examples include invoice numbers, batch ID’s, employee numbers, etc. Panorama can automatically assign a unique number to each new record as it is created, even if several people are using the database simultaneously over a network.

Setting up automatic record numbering should usually be done before you convert the database from single user to sharable. First set up the field that will contain the automatic record number. This field must be a numeric field. To specify that this field should contain a unique record number, the default should be + . Do not specify any increment value, just use a single + character. When you add the + sign in the default value Panorama will start numbering from 1, no matter what is already in the database. If you want to start with some other value you need to set that either manually (using the File>Database Options dialog), or in code (using the setautonumber statement).

Once the default is set up, share the database to the server (see Creating a Shared Database.

When a database is in single user mode, the next record counter is kept in the database itself. When a database is shared, the counter is kept on the server. Every time a new record is created, the local copy of Panorama will ask the server what the next record number should be (the server then automatically increments the counter for next time). Even if the record is later deleted, the number will never be re-used (unless you reset the counter manually as described below).

To illustrate how automatic numbering works, let鈥檚 assume that Bob Blue and Rudy Red have been hired to do some data entry on this personnel roster. The database starts out looking like this on both Bob and Rudy’s computers:

The first field, EmployeeID, has been set for automatic numbering. So far the employees have been assigned numbers from 1 to 7. Now Bob starts by adding a new record to the database. As you can see, this adds employee number 8 to the database. This screenshot shows what Bob sees as this point.

Before Bob can even enter any data, Rudy gets to work and adds a record himself. The server knows that 8 has already been used, so this is employee number 9. This screenshot shows what Rudy sees as this point.

Meanwhile Bob has finished entering the first record and adds another. This is employee number 10.

As they are adding new records, Bob and Rudy will not see the records added by each other (or anyone else). If they want to see all of the new records, they can simply choose Synchronize Data from the File menu, and the records entered by other users will appear.

If you want Panorama to automatically synchronize each time a new record is added, simply set up a .NewRecord procedure containing a synchronize statement. This procedure will automatically be triggered whenever a new record is added. See Implicitly Triggered Procedures for more information about .NewRecord procedures.

Manually Changing the Record Number Counter

The automatic record number normally increments by one each time a new record is added, but you can manually change the record number counter at any time using the Database Options dialog (in the File menu).

To change the next record ID # simply type in a new number and press Ok. For example, suppose you want the next employee number to be 50. Simply type in 50 and press Ok.

This change takes place immediately, so the next time a record is added, the employee number will be 50.

Keep in mind that this is the next record added anywhere on the network. If someone else adds a record before you do, you鈥檒l see 51, 52, or a higher number on your computer.

Accessing the Next Record Number in a Procedure

It is also possible to access and modify this ID number in a procedure with the GetAutoNumber and SetAutoNumber statements. To access the next record ID # use the GetAutoNumber statement. Here is a simple procedure that displays the next record ID number.

local id
GetAutoNumber id
message "The next record number will be "+str(id)+"."

Keep in mind that since this is a multi-user system someone else may use that number before you get a chance to, even if the addrecord statement is the next statement after the GetAutoNumber statement.

To change the next automatic record number use the SetAutoNumber statement. This one line procedure uses the SetAutoNumber statement to reset the record ID number to 1000.

SetAutoNumber 1000

This is exactly the same as setting the number with the Database Options dialog sheet.


See Also


History

VersionStatusNotes
10.2NewNew in this version.

两个鬼故事大村官之放飞梦想电视剧中国南海事件企业起名测名称开个农资店起个什么名字好呢林字起名男孩科技公司起名带水电视剧天若有情阴历九月出生的男孩起名字智能公司起名参考北京链家地产怎么样新金瓶梅2苏格拉底柏拉图包卜nba如何查询信用记录美女总裁爱上小保安陈扬最新章节娘子手下留情1990年日历用国字起名字麻辣烫店怎么起店名婴儿起名李免费英雄联盟双城之战在线观看五行八字起名的姓名测试新闻综合频道直播再审申请书范文王盛德gaysm店铺起名免费下载河南电信网上营业厅网址起名网倩女幽魂电视剧少年生前被连续抽血16次?多部门介入两大学生合买彩票中奖一人不认账让美丽中国“从细节出发”淀粉肠小王子日销售额涨超10倍高中生被打伤下体休学 邯郸通报单亲妈妈陷入热恋 14岁儿子报警何赛飞追着代拍打雅江山火三名扑火人员牺牲系谣言张家界的山上“长”满了韩国人?男孩8年未见母亲被告知被遗忘中国拥有亿元资产的家庭达13.3万户19岁小伙救下5人后溺亡 多方发声315晚会后胖东来又人满为患了张立群任西安交通大学校长“重生之我在北大当嫡校长”男子被猫抓伤后确诊“猫抓病”测试车高速逃费 小米:已补缴周杰伦一审败诉网易网友洛杉矶偶遇贾玲今日春分倪萍分享减重40斤方法七年后宇文玥被薅头发捞上岸许家印被限制高消费萧美琴窜访捷克 外交部回应联合利华开始重组专访95后高颜值猪保姆胖东来员工每周单休无小长假男子被流浪猫绊倒 投喂者赔24万小米汽车超级工厂正式揭幕黑马情侣提车了西双版纳热带植物园回应蜉蝣大爆发当地回应沈阳致3死车祸车主疑毒驾恒大被罚41.75亿到底怎么缴妈妈回应孩子在校撞护栏坠楼外国人感慨凌晨的中国很安全杨倩无缘巴黎奥运校方回应护栏损坏小学生课间坠楼房客欠租失踪 房东直发愁专家建议不必谈骨泥色变王树国卸任西安交大校长 师生送别手机成瘾是影响睡眠质量重要因素国产伟哥去年销售近13亿阿根廷将发行1万与2万面值的纸币兔狲“狲大娘”因病死亡遭遇山火的松茸之乡“开封王婆”爆火:促成四五十对奥巴马现身唐宁街 黑色着装引猜测考生莫言也上北大硕士复试名单了德国打算提及普京时仅用姓名天水麻辣烫把捣辣椒大爷累坏了

两个鬼故事 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化