darth sidious
Registered User.
- Local time
- Yesterday, 22:44
- Joined
- Feb 28, 2013
- Messages
- 86
you cant add autonumber to queries. You assign them to tables, then append query data to the table. (but not the autonum)
ah, I see. If you want to start the autonum over at zero, you need 2 target tables
1 to hold the new data, 1 a copy of the structure that never gets data ,(to keep autonum at zero)
I have tTarget and tTarget_MT tables
empty both tables then compress the db. (to start autonum at 0)
now everytime you add data to the table
copy tTarget_MT to tTarget
append data to tTarget.
(I have a macro that does this)
copy the virgin empty table to the working table
add data.
If you have something in the query that's unique so that an order can be established you can do this with a combination of a subquery, IIF function and DLookup as I have done in the attached database. I suspect that because of the subquery and DLookup that this would get pretty slow with enough records
I zipped it. Maybe that will help.
This was created with Access 2013 if that makes any difference.
I was going to say that all you need to do it make the query the record source of the form, but I tried that at which point I noticed that the query I came up with is not editable. So that probably won't work for you.
If you implement Ranman256's idea the data will be in another table so editing that wouldn't alter the original data either without putting in some code.
Could you tell us a little more about the purpose of this autonumber. Perhaps we can suggest some other way of accomplishing the end goal.