[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.vb.general.discussion

renumber records in acces table without using autonumbering

Catharinus van der werf

3/9/2012 4:46:00 PM

Hello my friends

I have build a vb6-program that among others things, can delete
records in an access -table. Each records contains a record-number
that is kept in a column with the name 'teller'. I don't use
autonumbering in this table. After deleting a record, the
recordnumbers that have a higher number than the deleted record,
should have a lower number. That can easily be arranged with the
following statement:
Call conconnection.execute("Update tableB set teller=teller-1")

But in the table mentioned, the recordnumbers don't follow each other
exactly, beacuse at first (for over a year) I forgot to change the
recordnumber like this. So now the numbers don't follow each other
simultanteously. Is there an easy solotion for again making the
recordnumber follow each other one by one?
Thanks

Catharinus van der Werf
csvanderwerf@gmail.com
20 Answers

MikeD

3/9/2012 6:16:00 PM

0



"Catharinus van der werf" <csvanderwerf@gmail.com> wrote in message
news:94da9be3-4069-4f06-bd25-f540605389c2@w1g2000vbx.googlegroups.com...
> Hello my friends
>
> I have build a vb6-program that among others things, can delete
> records in an access -table. Each records contains a record-number
> that is kept in a column with the name 'teller'. I don't use
> autonumbering in this table. After deleting a record, the
> recordnumbers that have a higher number than the deleted record,
> should have a lower number. That can easily be arranged with the
> following statement:
> Call conconnection.execute("Update tableB set teller=teller-1")
>
> But in the table mentioned, the recordnumbers don't follow each other
> exactly, beacuse at first (for over a year) I forgot to change the
> recordnumber like this. So now the numbers don't follow each other
> simultanteously. Is there an easy solotion for again making the
> recordnumber follow each other one by one?
> Thanks


The easiest, IMO, would probably be to create an identical temp table.
"Move" all records into the temp table and then re-insert them back into the
original table. I assume there are no relationships between this table and
any others, or at least none where this particular field is used as the link
between the 2 tables? If there is, then you're going to have to change it in
all of those tables too, which is doable, but a little more involved.
Without more details about the table and the database in general, kinda hard
to provide much of a specific answer.

A question that just kind of begs answering though is why are you even
concerned about this? So what if some numbers are skipped? Your program
shouldn't be dependent on them having to be sequential (and it doesn't sound
like it is, so that's good).

Mike


MikeB

3/9/2012 6:31:00 PM

0


"MikeD" <nobody@nowhere.edu> wrote in message
news:jjdhdk$m9d$1@dont-email.me...
>
>
> "Catharinus van der werf" <csvanderwerf@gmail.com> wrote in message
> news:94da9be3-4069-4f06-bd25-f540605389c2@w1g2000vbx.googlegroups.com...
>> Hello my friends
>>
>> I have build a vb6-program that among others things, can delete
>> records in an access -table. Each records contains a record-number
>> that is kept in a column with the name 'teller'. I don't use
>> autonumbering in this table. After deleting a record, the
>> recordnumbers that have a higher number than the deleted record,
>> should have a lower number. That can easily be arranged with the
>> following statement:
>> Call conconnection.execute("Update tableB set teller=teller-1")
>>
>> But in the table mentioned, the recordnumbers don't follow each other
>> exactly, beacuse at first (for over a year) I forgot to change the
>> recordnumber like this. So now the numbers don't follow each other
>> simultanteously. Is there an easy solotion for again making the
>> recordnumber follow each other one by one?
>> Thanks
>
>
> The easiest, IMO, would probably be to create an identical temp table.
> "Move" all records into the temp table and then re-insert them back into
> the original table. I assume there are no relationships between this table
> and any others, or at least none where this particular field is used as
> the link between the 2 tables? If there is, then you're going to have to
> change it in all of those tables too, which is doable, but a little more
> involved. Without more details about the table and the database in
> general, kinda hard to provide much of a specific answer.
>
> A question that just kind of begs answering though is why are you even
> concerned about this? So what if some numbers are skipped? Your program
> shouldn't be dependent on them having to be sequential (and it doesn't
> sound like it is, so that's good).

Usually this numberthink is related to OCD (I can sympathize), but a
numbering scheme in a database should hold no realworld visual meaning.
Even if it were to hardcode the sequencing of the records, out of incidence
numbers work the same.

I would like to see the OP answer just the same.


>
> Mike
>
>


Catharinus van der werf

3/10/2012 12:25:00 AM

0

On 9 mrt, 19:30, "MikeB" <m.byer...@frontier.com> wrote:
> "MikeD" <nob...@nowhere.edu> wrote in message
>
> news:jjdhdk$m9d$1@dont-email.me...
>
>
>
>
>
>
>
> > "Catharinus van der werf" <csvanderw...@gmail.com> wrote in message
> >news:94da9be3-4069-4f06-bd25-f540605389c2@w1g2000vbx.googlegroups.com...
> >> Hello my friends
>
> >> I have build a vb6-program that among others things, can delete
> >> records in an access -table. Each records contains a record-number
> >> that is kept in a column with the name 'teller'.  I don't use
> >> autonumbering in this table.  After deleting a record, the
> >> recordnumbers that have a higher number than the deleted record,
> >> should have a lower number. That can easily be arranged with the
> >> following statement:
> >> Call conconnection.execute("Update tableB  set teller=teller-1")
>
> >> But in the table mentioned, the recordnumbers don't follow each other
> >> exactly, beacuse at first (for over a year) I forgot to change the
> >> recordnumber like this. So now the numbers don't follow each other
> >> simultanteously. Is there an easy solotion for again making the
> >> recordnumber follow each other one by one?
> >> Thanks
>
> > The easiest, IMO, would probably be to create an identical temp table.
> > "Move" all records into the temp table and then re-insert them back into
> > the original table. I assume there are no relationships between this table
> > and any others, or at least none where this particular field is used as
> > the link between the 2 tables? If there is, then you're going to have to
> > change it in all of those tables too, which is doable, but a little more
> > involved. Without more details about the table and the database in
> > general, kinda hard to provide much of a specific answer.
>
> > A question that just kind of begs answering though is why are you even
> > concerned about this? So what if some numbers are skipped? Your program
> > shouldn't be dependent on them having to be sequential (and it doesn't
> > sound like it is, so that's good).
>
>   Usually this numberthink is related to OCD (I can sympathize), but a
> numbering scheme in a database should hold no realworld visual meaning.
> Even if it were to hardcode the sequencing of the records, out of incidence
> numbers work the same.
>
>   I would like to see the OP answer just the same.
>
>
>
>
>
> > Mike- Tekst uit oorspronkelijk bericht niet weergeven -
>
> - Tekst uit oorspronkelijk bericht weergeven -- Tekst uit oorspronkelijk bericht niet weergeven -
>
> - Tekst uit oorspronkelijk bericht weergeven -

thanks Mike, I'll think things over again

Tony Toews

3/10/2012 7:18:00 PM

0

On Fri, 9 Mar 2012 13:30:32 -0500, "MikeB" <m.byerley@frontier.com>
wrote:

>> A question that just kind of begs answering though is why are you even
>> concerned about this? So what if some numbers are skipped? Your program
>> shouldn't be dependent on them having to be sequential (and it doesn't
>> sound like it is, so that's good).
>
> Usually this numberthink is related to OCD (I can sympathize), but a
>numbering scheme in a database should hold no realworld visual meaning.
>Even if it were to hardcode the sequencing of the records, out of incidence
>numbers work the same.

While I don't mean to pile on I was thinking exactly the same. In
Access missing autonumber values happen all the time if a person
starts to enter a record in Access and then backs out of the form.
But the users should never see that autonumber so no big deal.

(That said I do expose the autonumber in one case but just as a visual
aid.)

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/ac...
Tony's Microsoft Access Blog - http://msmvps.com/blo...
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeup...

MikeB

3/10/2012 8:43:00 PM

0

Number 7. (mine btw)
http://access.mvps.org/access/tencomman...



"Tony Toews" <ttoews@telusplanet.net> wrote in message
news:93anl75g4jdbahthmjb6bopi307stshred@4ax.com...
> On Fri, 9 Mar 2012 13:30:32 -0500, "MikeB" <m.byerley@frontier.com>
> wrote:
>
>>> A question that just kind of begs answering though is why are you even
>>> concerned about this? So what if some numbers are skipped? Your program
>>> shouldn't be dependent on them having to be sequential (and it doesn't
>>> sound like it is, so that's good).
>>
>> Usually this numberthink is related to OCD (I can sympathize), but a
>>numbering scheme in a database should hold no realworld visual meaning.
>>Even if it were to hardcode the sequencing of the records, out of
>>incidence
>>numbers work the same.
>
> While I don't mean to pile on I was thinking exactly the same. In
> Access missing autonumber values happen all the time if a person
> starts to enter a record in Access and then backs out of the form.
> But the users should never see that autonumber so no big deal.
>
> (That said I do expose the autonumber in one case but just as a visual
> aid.)
>
> Tony
> --
> Tony Toews, Microsoft Access MVP
> Tony's Main MS Access pages - http://www.granite.ab.ca/ac...
> Tony's Microsoft Access Blog - http://msmvps.com/blo...
> For a convenient utility to keep your users FEs and other files
> updated see http://www.autofeup...


ralph

3/11/2012 1:31:00 AM

0

On Sat, 10 Mar 2012 12:18:14 -0700, Tony Toews
<ttoews@telusplanet.net> wrote:

>On Fri, 9 Mar 2012 13:30:32 -0500, "MikeB" <m.byerley@frontier.com>
>wrote:
>
>>> A question that just kind of begs answering though is why are you even
>>> concerned about this? So what if some numbers are skipped? Your program
>>> shouldn't be dependent on them having to be sequential (and it doesn't
>>> sound like it is, so that's good).
>>
>> Usually this numberthink is related to OCD (I can sympathize), but a
>>numbering scheme in a database should hold no realworld visual meaning.
>>Even if it were to hardcode the sequencing of the records, out of incidence
>>numbers work the same.
>
>While I don't mean to pile on I was thinking exactly the same. In
>Access missing autonumber values happen all the time if a person
>starts to enter a record in Access and then backs out of the form.
>But the users should never see that autonumber so no big deal.
>
>(That said I do expose the autonumber in one case but just as a visual
>aid.)
>
>Tony

To add to the pile <g> ...

It should be pointed out that while Access will do it its best to
insure integrity and uniqueness when requested - it (like all
databases) will never guarantee concurrency.

-ralph

MikeB

3/11/2012 3:43:00 AM

0


"ralph" <nt_consulting64@yahoo.net> wrote in message
news:fpvnl7159uemcgbeaoscqa7dr3658l53ib@4ax.com...
> On Sat, 10 Mar 2012 12:18:14 -0700, Tony Toews
> <ttoews@telusplanet.net> wrote:
>
>>On Fri, 9 Mar 2012 13:30:32 -0500, "MikeB" <m.byerley@frontier.com>
>>wrote:
>>
>>>> A question that just kind of begs answering though is why are you even
>>>> concerned about this? So what if some numbers are skipped? Your program
>>>> shouldn't be dependent on them having to be sequential (and it doesn't
>>>> sound like it is, so that's good).
>>>
>>> Usually this numberthink is related to OCD (I can sympathize), but a
>>>numbering scheme in a database should hold no realworld visual meaning.
>>>Even if it were to hardcode the sequencing of the records, out of
>>>incidence
>>>numbers work the same.
>>
>>While I don't mean to pile on I was thinking exactly the same. In
>>Access missing autonumber values happen all the time if a person
>>starts to enter a record in Access and then backs out of the form.
>>But the users should never see that autonumber so no big deal.
>>
>>(That said I do expose the autonumber in one case but just as a visual
>>aid.)
>>
>>Tony
>
> To add to the pile <g> ...
>
> It should be pointed out that while Access will do it its best to
> insure integrity and uniqueness when requested - it (like all
> databases) will never guarantee concurrency.

Ralph,
Exception to "all" databases.
You should go back and read the history of RBase.
Concurrency control is at the engine level and is absolutely guaranteed.

> -ralph


ralph

3/11/2012 2:45:00 PM

0

On Sat, 10 Mar 2012 22:42:33 -0500, "MikeB" <m.byerley@frontier.com>
wrote:

>
>"ralph" <nt_consulting64@yahoo.net> wrote in message
>news:fpvnl7159uemcgbeaoscqa7dr3658l53ib@4ax.com...
>> On Sat, 10 Mar 2012 12:18:14 -0700, Tony Toews
>> <ttoews@telusplanet.net> wrote:
>>
>>>On Fri, 9 Mar 2012 13:30:32 -0500, "MikeB" <m.byerley@frontier.com>
>>>wrote:
>>>
>>>>> A question that just kind of begs answering though is why are you even
>>>>> concerned about this? So what if some numbers are skipped? Your program
>>>>> shouldn't be dependent on them having to be sequential (and it doesn't
>>>>> sound like it is, so that's good).
>>>>
>>>> Usually this numberthink is related to OCD (I can sympathize), but a
>>>>numbering scheme in a database should hold no realworld visual meaning.
>>>>Even if it were to hardcode the sequencing of the records, out of
>>>>incidence
>>>>numbers work the same.
>>>
>>>While I don't mean to pile on I was thinking exactly the same. In
>>>Access missing autonumber values happen all the time if a person
>>>starts to enter a record in Access and then backs out of the form.
>>>But the users should never see that autonumber so no big deal.
>>>
>>>(That said I do expose the autonumber in one case but just as a visual
>>>aid.)
>>>
>>>Tony
>>
>> To add to the pile <g> ...
>>
>> It should be pointed out that while Access will do it its best to
>> insure integrity and uniqueness when requested - it (like all
>> databases) will never guarantee concurrency.
>
> Ralph,
> Exception to "all" databases.
> You should go back and read the history of RBase.
> Concurrency control is at the engine level and is absolutely guaranteed.
>

Ha. Well one can always get into trouble when they say "all", and
equal misfortune can fall to one that doesn't fully explain their
usage of a term.

Database concurrency is generally defined as the ability of multiple
users to read or write the same data at the same time with out
collision issues (excessive blocking or loss of integrity). Many RDBMS
provide for the user to setup and manage concurrency with locking
schemes, others facilitate the process with built-in "concurrency"
algorithms and options. R:Base, as you noted, was one of the early
adopters of the latter. SQL Server, on the other hand, didn't provide
a specific "currency" option until later in its career (2005?).

However, there is another form of "concurrency"; the ability to insure
any record is located (logically or physically) at an exact ordinal
position, or that sequence numbers (autonumbers, etc.) are applied in
order (in sequence without 'gaps'). That kind of concurrency is never
guaranteed by any database and any assumptions that it is some how
inherently handled always leads to surprises and disappointment.

Any time there is a requirement for a specific ordinal arrangement
then that requirement must be specifically designed for.

-ralph

ralph

3/11/2012 2:50:00 PM

0

On Sun, 11 Mar 2012 09:45:04 -0500, ralph <nt_consulting64@yahoo.net>
wrote:

Oops!

>... SQL Server, on the other hand, didn't provide
>a specific "currency" option until later in its career (2005?).
>

Meant "concurrency" not "currency". <g>

-ralph

ralph

3/11/2012 3:21:00 PM

0

On Fri, 9 Mar 2012 08:45:46 -0800 (PST), Catharinus van der werf
<csvanderwerf@gmail.com> wrote:

>Hello my friends
>
>I have build a vb6-program that among others things, can delete
>records in an access -table. Each records contains a record-number
>that is kept in a column with the name 'teller'. I don't use
>autonumbering in this table. After deleting a record, the
>recordnumbers that have a higher number than the deleted record,
>should have a lower number. That can easily be arranged with the
>following statement:
>Call conconnection.execute("Update tableB set teller=teller-1")
>
>But in the table mentioned, the recordnumbers don't follow each other
>exactly, beacuse at first (for over a year) I forgot to change the
>recordnumber like this. So now the numbers don't follow each other
>simultanteously. Is there an easy solotion for again making the
>recordnumber follow each other one by one?
>Thanks

I'm not a fan of any attempt to maintain associations "in record".

To me, and with the full understanding I don't really know why this is
even necessary <g>, it seems this would be best handled with a
separate association table that ties a "teller number" with a specific
record. The "teller" field is likely not even needed.

-ralph