Solved

autonumber problem

Posted on 2001-08-14
8
227 Views
Last Modified: 2010-04-06
Ok, I've suppose I have the following table:

IdCustomer || Name || Address || etc, etc, etc
==============================================
autonumber    alpha    alpha
----------------------------------------------

I call datamodule.clientdataset.append;
The user enters all data and then
I call datamodule.clientdataset.applyupdates(-1);

This works just fine. But what happens if I want some label of mine to show the IdCustomer the user is just entering now. I mean, while the user enters all data I want a label to show the autonumber. However, this is not as easy as it may seem, because the autonumber, apparenttly is generated when I call datamodule.clientdataset.applyupdates(-1);

Is there any way to calculate autonumber fields before the user enters data in the new record?

thanks.
paul.
0
Comment
Question by:pin_plunder
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
for paradox,
there is a (tricky) way to lookup the next generated number without to get it
(you need fileaccess to the table)
(not recommended for multiuser-access)
0
 
LVL 4

Accepted Solution

by:
YodaMage earned 50 total points
Comment Utility
Autoinc in Paradox is not good at all. You are better off keeping a table with int values seperate, then having a global procedure to get value, then inc value in table. This is basically a mimic of a SQL generator.
0
 

Expert Comment

by:comptebidon81
Comment Utility
Or may I suggest you to Force a Post when the user starts editing. Your Index will be updated and you won't have to de anything tricky to get the number...
GunDamn
0
 

Author Comment

by:pin_plunder
Comment Utility
I'm sorry to say this but I thought I was the one who was wrong or missed something, but now I clearly see that the guys who made paradox are not very clever, are they?

thanks all for your help. although there wasn't much to say.
paul.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
> the guys who made paradox are not very clever, are they?

this i would not say, just look at paradox history

its an old desktop-database comes up ~1990 and
was the first multiuser desktop-database on market

0
 
LVL 3

Expert Comment

by:rondi
Comment Utility
You could:
 - read the previous record's AutoInc field into variable
   and just add 1 and display it (don't post it)

 - or like comptebidon81 hinted, when the user starts
   editing, do an Append followed by a Post (fill in any
   required fields with junk first) and then Edit the
   record (clearing any junk before displaying)

rondi.
0
 
LVL 4

Expert Comment

by:YodaMage
Comment Utility
rondi- The problem there is the multi-user aspect, and the fact that the autoinc value is not assigned until the post. Say I enter the app first and start to insert, with 100 being the next logical value from the previous record of 99. Then you enter the system after me, and do the same action, being 101. If you post your record first, you will end up 100 with me being 101. With more users and more data entry, the problem multiplies.

Removeing autoinc fields in favor of an integer field that you manually assign solves the issue as already said, by simulating a generator. It involves more code, but allows you to assign and increment the count on any event you like instead of being tied to the post event. You also have the benefit of manually ajusting the generator if needed.
0
 

Author Comment

by:pin_plunder
Comment Utility
thanks, thanks, thanks.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now