A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Use of query to add sequential numbers to a table.



 
 
Thread Tools Display Modes
  #1  
Old July 25th, 2004, 02:43 AM
Frank Martin
external usenet poster
 
Posts: n/a
Default Use of query to add sequential numbers to a table.

My InvoiceLines table uses the autonumber field for the primary key.

But I need another auto-incrementing field for the sort field.

Can such a field be genererated in the query by means of an expression, and
if so which one?

Please help, Frank


  #2  
Old July 25th, 2004, 03:54 AM
Duane Hookom
external usenet poster
 
Posts: n/a
Default Use of query to add sequential numbers to a table.

Are you asking if you can dynamically generate a value/column in a query or
do you think you need to store the value? Do you have some field or fields
that will determine the new sort order?

--
Duane Hookom
MS Access MVP


"Frank Martin" wrote in message
...
My InvoiceLines table uses the autonumber field for the primary key.

But I need another auto-incrementing field for the sort field.

Can such a field be genererated in the query by means of an expression,

and
if so which one?

Please help, Frank




  #3  
Old July 25th, 2004, 12:28 PM
Dale Fye
external usenet poster
 
Posts: n/a
Default Use of query to add sequential numbers to a table.

Frank,

Use the DMAX function, in conjunction with the NZ function, as below:

NZ(DMAX("SortOrder", "yourTable"), 0) + 1

This looks for the maximum value in the SortOrder field, then adds one to
it. If there are no valid entries in SortOrder, DMAX will return a NULL, so
you have to use NZ to convert that to a zero, before the addition.

HTH
Dale

"Frank Martin" wrote in message
...
My InvoiceLines table uses the autonumber field for the primary key.

But I need another auto-incrementing field for the sort field.

Can such a field be genererated in the query by means of an expression,

and
if so which one?

Please help, Frank




  #4  
Old July 26th, 2004, 01:56 AM
Frank Martin
external usenet poster
 
Posts: n/a
Default Use of query to add sequential numbers to a table.

Thanks, I'll try this.


"Dale Fye" wrote in message
...
Frank,

Use the DMAX function, in conjunction with the NZ function, as below:

NZ(DMAX("SortOrder", "yourTable"), 0) + 1

This looks for the maximum value in the SortOrder field, then adds one to
it. If there are no valid entries in SortOrder, DMAX will return a NULL,

so
you have to use NZ to convert that to a zero, before the addition.

HTH
Dale

"Frank Martin" wrote in message
...
My InvoiceLines table uses the autonumber field for the primary key.

But I need another auto-incrementing field for the sort field.

Can such a field be genererated in the query by means of an expression,

and
if so which one?

Please help, Frank






  #5  
Old July 26th, 2004, 01:58 AM
Frank Martin
external usenet poster
 
Posts: n/a
Default Use of query to add sequential numbers to a table.

I need something to act as an 'autonumber', in the field of my choice, even
when the PK is an autonumber.

I need it for the 'sorting field' and also for incrementing invoice numbers.



"Duane Hookom" wrote in message
...
Are you asking if you can dynamically generate a value/column in a query

or
do you think you need to store the value? Do you have some field or fields
that will determine the new sort order?

--
Duane Hookom
MS Access MVP


"Frank Martin" wrote in message
...
My InvoiceLines table uses the autonumber field for the primary key.

But I need another auto-incrementing field for the sort field.

Can such a field be genererated in the query by means of an expression,

and
if so which one?

Please help, Frank






 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Force Blank Lines jnew Setting Up & Running Reports 8 July 21st, 2004 09:45 PM
Complicated Databse w/many relationships Søren Database Design 7 July 13th, 2004 05:41 AM
Update another table with a Max record query Ngan Running & Setting Up Queries 2 June 22nd, 2004 05:01 PM
Edit table using union query De'Ville Running & Setting Up Queries 1 June 1st, 2004 11:46 AM
Lookup fields - what's wrong with them? NATHAN SANDERS New Users 2 May 4th, 2004 10:51 AM


All times are GMT +1. The time now is 09:25 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.