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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
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 |