22. februar 2003 - 10:38Der er
14 kommentarer og 2 løsninger
Nulstille autoincline
Jeg har en access database med et felt der er unikt samt automatisk stigende. Selvom jeg sletter alle poster i databasen, vil det felt altid stige fra den sidst tilføjede række. Er der nogen måde at nulstille det felt så det starter fra 1 på ny? Jeg ser gerne et vbscript.
I et stadigt mere komplekst trussel landskab, hvor sofistikerede cyberangreb, ransomware og datalækager udgør en konstant risiko, er IT-sikkerhed for længst rykket direkte ind i bestyrelseslokalet.
when you compress a dB it must be open in exclusive mode (one user). This means that you have to make sure no other users are using the dB. Then you may just as well copy the dB to your PC, compress the dB and then upload it again.
When you compress a dB it actually makes a copy of the original.
If you can reset your "UNIQUE" field starting at 0 again then I assume that it is NOT used as a foreign key in other related tables. So in my opinion I see no reason for reseting the number.
=D, I'll try to be more polite. But i really need to do it this since i call the row in the db from the id over irc chat. So the thing is, every time i need to call a row i write ".blahblah 1524" which is no problem at all, but now there is starting to become 5 decimal numbers in the db. But i only have around 100 rows in the db simonstaniously.
I dont know ANYTHING about "irc chat" so I can only make suggestions based on my knowledge of Access and databases.
What you are saying is you want a "UNIQUE" number between 1 and 9999 (max) and then you start at 1 again?
If this is the case then I would NOT suggest you reset the number by compressing your dB, but to make some function which stores the next number in a field in a table in your dB. So when you create a new record you query your table to get the next value, increment (increase) the value by 1, which will be used in the next record. When this number gets to 9999 it stores 1 in the field. Then instead of having an autonumber you have your own "UNIQUE" key.
Synes godt om
Slettet bruger
22. februar 2003 - 11:55#12
ah ok, but that shouldnt be neccesary at all, since all the data from the db is flushed when i update it.
If its the easiest way; im considering just making a master file of the db and then copy it into the dir every time i need to update it. Was just hoping for a better way.
Your idea of copying the master file to the dir is a VERY good solution as these keeps you database very small. Access databases DO grow and fill more space, and as I mentioned previously compressing your dB makes a copy of the original (without the waisted space of course). Believe me compressing the dB is NOT the easiest method.
En nem måde at danne det nye nøglefelt, som Terry foreslår, på er at beregne det direkte ud fra autonummereringsfeltet med: [IDNR] = [ID] MOD 10000 (lige efter at posten er gemt). Du får ganske vist numrene 0 - 9999, men det skulle ikke give nogen komplicationer.
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.