pin_plunder
asked on
autonumber problem
Ok, I've suppose I have the following table:
IdCustomer || Name || Address || etc, etc, etc
========================== ========== ==========
autonumber alpha alpha
-------------------------- ---------- ----------
I call datamodule.clientdataset.a ppend;
The user enters all data and then
I call datamodule.clientdataset.a pplyupdate s(-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.a pplyupdate s(-1);
Is there any way to calculate autonumber fields before the user enters data in the new record?
thanks.
paul.
IdCustomer || Name || Address || etc, etc, etc
==========================
autonumber alpha alpha
--------------------------
I call datamodule.clientdataset.a
The user enters all data and then
I call datamodule.clientdataset.a
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.a
Is there any way to calculate autonumber fields before the user enters data in the new record?
thanks.
paul.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
GunDamn
ASKER
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.
thanks all for your help. although there wasn't much to say.
paul.
> 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
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
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.
- 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.
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.
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.
ASKER
thanks, thanks, thanks.
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)