Solved

autonumber problem

Posted on 2001-08-14
8
244 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
ID: 6385385
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
ID: 6385579
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
ID: 6386008
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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 

Author Comment

by:pin_plunder
ID: 6386795
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6387277
> 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
ID: 6387628
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
ID: 6388544
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
ID: 6391171
thanks, thanks, thanks.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

820 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