Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 15th, 2007, 12:17 AM
Registered User
 
Join Date: Feb 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Serial Number with each table row

I want to view [u]Sr. No.</u> along with table row. As in Oracle we have rownum variable that we use to print Sr. No.
In Oracle ie: "Select RowNum, EmpName, City from Employee"
In Access : ???????????
Thanks,
Ketan N Sharma
 
Old March 15th, 2007, 06:40 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You can use the autonumber data type and create a primary key, and it works like the rownum in Oracle, or identity column in SQL.

So tblEmployee:
EmployeeID - autonumber
EmpFName - text
EmpLName - text
City - text

SELECT EmployeeID, EmpFName, EmpLName, City
FROM tblEmployee
...


HTH

mmcdonal
 
Old March 15th, 2007, 10:26 PM
Registered User
 
Join Date: Feb 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
I want to start Sr. No. from 1. Using Autonumber field It is not neccessary to that it will start from 1. Again When we delete row then autonumber field get affected. When we use WhERE condition in SQL then also it not start from 1.
so, I cannot use autonumber.
Any other Solution?
Regards,
Ketan N Sharma

Quote:
quote:Originally posted by mmcdonal
 You can use the autonumber data type and create a primary key, and it works like the rownum in Oracle, or identity column in SQL.

So tblEmployee:
EmployeeID - autonumber
EmpFName - text
EmpLName - text
City - text

SELECT EmployeeID, EmpFName, EmpLName, City
FROM tblEmployee
...


HTH

mmcdonal
 
Old March 16th, 2007, 06:44 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I am not sure why you would want all your downstream serial numbers to change when you delete one record upstream.

If you must, do not store the number field in the database, but generate it at runtime when you open a form or report.

Why do you want your serial numbers to change when one is deleted? Potentially a SN can change once a minute for days at a time given the right activity. What if someone is in the middle of processing a transaction and their SN is reordered?

I would suggest NOT deleting the records, but marking them inactive, so that the other SN's do not change if you have to use this scheme.


mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
Hard Disk Serial Number preetha Ajayan C# 2005 3 June 20th, 2007 06:44 PM
how to get hard disk serial number in c# imran_mani .NET Framework 1.x 0 May 7th, 2007 03:45 AM
Hard disk serial number alexjiju VS.NET 2002/2003 1 February 3rd, 2007 02:50 PM
Integrating a serial number madhukp VB How-To 4 March 22nd, 2005 09:15 AM
Serial number Ned SQL Server 2000 6 November 6th, 2003 05:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.