Page 1 of 1

Unique field duplicates value

PostPosted: Tue Apr 12, 2016 8:52 am
by chungfoulds
I have an invoice database with a unique field that I use to identify each invoice. On doing my accounts I have found that the unique field has generated the same ID number on several occasions. Not all the time, just occasionally, has ahyone experienced similar behaviour.

Re: Unique field duplicates value

PostPosted: Tue Apr 12, 2016 8:31 pm
by Treanot
I ran into this problem and there were several answers already in the forums that explains the reason why and some solutions. I also tried the generating a unique number using the date and time then dividing it by a number technique, also explain in this forum, but found the number was too long. My solution in generating a ID number was to keep a count using these 3 fields:
Startvalue calculated (id+increase)
id integer start value of precious Startvalue
Increase integer static value of 1

There are still several issue with this. The first record will be 0 and you need to sort by ID number so that the last highest ID record starts the count. You will see what I mean after you start using it.

Of course this gets more complicated if you want to use multiple Devices simultaneously.
That is a different question completely.

Good luck.

Re: Unique field duplicates value

PostPosted: Wed Apr 13, 2016 11:43 am
by chungfoulds
Thanks, I had done a search but it came up blank, found some replies today though! They are way more complicated than I need as I only have one device that I input on. It seems that the problem may be related to 'copy to new' command and/or using different views of a single database and entering data in those views as opposed to the base view, together with adding new records with backdated dates. In short, messing with the database !! thanks for the comments

Re: Unique field duplicates value

PostPosted: Sun Apr 17, 2016 12:51 pm
by Brian_Houghton
The unique field can unfortunately generate duplicate values in certain scenarios and is considered a "legacy" field, left in for compatibility purposes but not fully accurate. The reason it can generate duplicate values is due to the way the internals of HanDBase generates values.

If you are using iOS, you may want to consider combining a series of values using the concatenate feature of the external field. Doing so you can add the values of an integer that adds 1 to itself with each new record, add the time the record was created, add the date the record was created and more based on your needs. Doing so will give you a unique number for each of your records.

Re: Unique field duplicates value

PostPosted: Mon Apr 18, 2016 10:43 am
by Treanot
I will add that the PC version does not support concatenate field. If you do any key entry on the Computer you will have a "null" field. It does export the value from IOS to PC and you will have a field value when you sync . But the PC desktop does not support combining external field and thus you can not join field on the desktop it really a feature that is missed. The work around is if combine field is blank then then value else not combined value (off the top of my head I don't remember).
Then you start running into issues that the conditional statements don't show up live until after the entry in saved, or an external Popup is prior to the condition.