 |
| 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
|
|
|
|

March 15th, 2007, 12:17 AM
|
|
Registered User
|
|
Join Date: Feb 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

March 15th, 2007, 06:40 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
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
|
|

March 15th, 2007, 10:26 PM
|
|
Registered User
|
|
Join Date: Feb 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
|

March 16th, 2007, 06:44 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
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
|
|
 |