Issue with time stamp

mrtn

Registered User.
Local time
Today, 19:40
Joined
Dec 16, 2010
Messages
43
Hi

I use the following as a time stamp:

Code:
DateStamp = Format(Now, "dd.mm.yyyy hh-nn-ss")

Quite sensibly, every single time I refer to (in different time intervals) the 'DateStamp', it uses current time therefore every time stamp is different.

Is there any way to "save" the time stamp so on every occasion I refer to it, it uses the same value? I.e. the Now() function would be run once and the set as variable or something like that? For instance

1. I refer to time stamp on 20.09.2012 19-25-01

The time stamp is used in various actions

2. I then need to refer to the same time stamp as above but the current time stamp is current time for example 20.09.2012 19-30-25.

Is there any way to use time stamp from no.1 when that time stamp is no longer valid?

Any help is much appreciated.
 
Create a variable in a standard module's GENERAL DECLARATIONS section like:

Public dteTimeStamp As Date

Then you can set it from wherever

dteTimeStamp = Now

and then use it in multiple places.
 
Brilliant!! Thanks for that.

I will test tomorrow and report back.
 
What is the purpose of using a datetime as a string? And perhaps storing it even? All sorting will then be alphabetical, or a conversion back into a datetime would be required.
 
It's a long story but I have got a database that exports trade orders to excel based on an order type i.e. buy or sell and a reference number.

Firstly orders are grouped by order type and then by reference number, so I get Access to export individual spreadsheet containing the same orders by type and reference in bulk. The time stamp is added in the name of each of the files just as an audit trail and also helps to distinguish spreadsheets. The export time takes few seconds and during this time number of time stamps is created resulting in spreadsheets not being grouped properly as I get couple spreadsheets for the same reference number but with different time stamp in name.

Sorry but I don't think I could make it any clearer.

By the way I think the original code that allows me to export is courtesy of Bob :)
 

Users who are viewing this thread

Back
Top Bottom