![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
It seems like this ought to be easy, and I'm sure it is, I just haven't figure out how to make it easy. I have data in a secondary table that I have been cleaning up so I can insert into my primary table. The last step is to update a converted index field (added by access when the data was imported from excel, and irrelevant to the primary table) in each record with an incremental value. So, the first record gets "7000", the second gets "7001", and so forth. (This will be part of the key in the primary table) To make this more fun, there are groups of records that I want to get numbered together, so I made a query that can pull each group and sort it appropriately. The table name is tblDrCbList. The query is qrySortDrCbs. The field I am over-writing is ID. Any help in pointing out simple solution I'm missing is greatly appreciated. Thanks. Tim I don't know if the primary table has an autonumber. Anyway, I might |
#3
| |||
| |||
|
|
I don't know if the primary table has an autonumber. *Anyway, I might first append all the records and assign Null to the counter field. After the append, select all records from primary where autonum field is greater than when you appended sorted by the autonum. *THen loop thru that recordset, adding 1 the current starting number. *The initial val of the starting num would be 6999.- Hide quoted text - - Show quoted text - |
#4
| |||
| |||
|
|
It seems like this ought to be easy, and I'm sure it is, I just haven't figure out how to make it easy. I have data in a secondary table that I have been cleaning up so I can insert into my primary table. The last step is to update a converted index field (added by access when the data was imported from excel, and irrelevant to the primary table) in each record with an incremental value. So, the first record gets "7000", the second gets "7001", and so forth. (This will be part of the key in the primary table) To make this more fun, there are groups of records that I want to get numbered together, so I made a query that can pull each group and sort it appropriately. The table name is tblDrCbList. The query is qrySortDrCbs. The field I am over-writing is ID. Any help in pointing out simple solution I'm missing is greatly appreciated. Thanks. Tim |
#5
| |||
| |||
|
|
Not too sure what you mean by 'numbered together', if you just mean that you want the numbers for these records to be in a contiguous sequence then this can be done but is a bad design. If the above is the intention then you are better off adding a 'grouping' field so that you can easily add items to the group with out having to worry about re-sequencing the ID field. Anyway, bit of code to get you started, make sure you test this on a backup of the data not on your working copy. dim lodb as dao.database dim rs as dao.recordset dim lngCount as long set lodb = currentdb set rs = lodb.openrecordset("SELECT [ID} FROM qrySortDrCbs") lngCount = 6999 with rs * * do until .eof * * * * lngCount = lngCount + 1 * * * * .Edit * * * * .Fields("ID") = lngCount * * * * .Update * * * * .movenext * * loop * * .Close end with set rs = nothing set loDb = Nothing Note this will only work if your query is an updatable query. -- Terry Kreft "Tim Olson" <bassman... (AT) gmail (DOT) com> wrote in message news:b222625f-6a8d-48fa-baac-e74bfeff0400 (AT) w18g2000vbe (DOT) googlegroups.com... It seems like this ought to be easy, and I'm sure it is, I just haven't figure out how to make it easy. I have data in a secondary table that I have been cleaning up so I can insert into my primary table. *The last step is to update a converted index field (added by access when the data was imported from excel, and irrelevant to the primary table) in each record with an incremental value. So, the first record gets "7000", the second gets "7001", and so forth. (This will be part of the key in the primary table) To make this more fun, there are groups of records that I want to get numbered together, so I made a query that can pull each group and sort it appropriately. The table name is tblDrCbList. The query is qrySortDrCbs. The field I am over-writing is ID. Any help in pointing out simple solution I'm missing is greatly appreciated. Thanks. Tim- Hide quoted text - - Show quoted text - |
![]() |
| Thread Tools | |
| Display Modes | |
| |