Unique Time Stamp

  • Thread starter Thread starter jmawebco
  • Start date Start date
J

jmawebco

I have a process by which data is updated in a temp table and when the
user is done and clicks a "Finish" button all the data from the temp
table is moved to a permanent table. What I want to do is set a unique
time stamp for each record before they are moved to the permanent
table. The time stamp has to be unique for each and every record so I
can't just use the "Format(Now(),yyyymmddhhmmss)" command as this will
put the same time stamp for all records.

If anyone knows how I can do this please let me know.

Thanks!!
 
Set the field's Default value to Now(), and don't populate it when you're
moving the data so that it picks up the default.
 
Hi,


If you add only one record at a time, you can use an extra field, in the
table, with a default value like:


= Now( )


The precision is to the second, which is not funny if you insert 10
records/sec.


You can add a constraint of "no duplicated value" to enforce uniqueness on
this "computed" field.


Hoping it may help,
Vanderghast, Access MVP
 
This would work fine but since multiple records are being added at once
it would create duplicates and that can not happen.
 
This is what I'm trying to do;

in the append command make the field value equal to
"Format(Now(),yyyymmddhhmm) + x" X here represent the value assigned in
a for next loop.

The idea is to generate a unique value for each record added and my
initial idea seemed to give me that but it is not working. The time
stamp is added but the value of x is not being added to the timestamp
before it is inserted into the database.
 
Hi,


As Rob pointed out, in this case, you can also add a standard autoincrement
field and use BOTH fields (the =Now() and the autoIncrement) as potential
key. Indeed, even if you add "n" records in a batch, they are likely to get
all the same timestamp (to the closest second), but the autoincrement will
be different, playing the role of you "X", but in a different field.

You can then join both fields in a query, through concatenation of their
string representation.

Hoping it may help,
Vanderghast, Access MVP
 
Would it be possible for you to give me a sample of what you are
talking about? I thought about combining the timestamp with an
autoincrement number but can't seem to get the end result desired. I
guess I'm not formating the combination of the two items properly. If
you can give me a simple example I would be very grateful.
 
Hi,



Sounds like


SELECT Format(timeStampField, "yyyymmddhhnnss") & "-" &
CStr(autonumberField)
FROM myTable



where I used a - to delimit the timestamp and the autonumber generated
field value.


Hoping it may help,
Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top