[AccessD] Help, date diff

Stuart McLachlan stuart at lexacorp.com.pg
Wed Oct 8 22:48:59 CDT 2003


On 8 Oct 2003 at 22:59, Oleg_123 at xuppa.com wrote:

> Hey Group
> I have to do procedure that checks if macro was already executed today (in
> the last 14 hrs) and if yes doesn't do it again. I am taking last time it
> was created from a table that contains only one record. Can someone please
> remind me on how do I put the new value back into the table ? Write now I
> get the error message that current database doesn't support update...

It doesn't if you get if as you have done below.

> Also, do  Ineed to use ADO, or can do without if the table with date value
> is in the same database ?

If the tables are either in the same mdb or linked, you can do it without 
ADO like this (assuming that Table1 is a single record  "System File":

last_time = DLookup("gina","Table1")
nnow = Now()
andy = DateDiff("h", last_time, nnow)
 
 If andy > 14 Then
     DoCmd.Setwarnings False
     DoCmd.RunSQL "Update Table1 Set gina  = Now()"
     DoCmd.Setwarnings True
    Else
     MsgBox ("The function was already performed today")
 End If

Alternatively, using ADO, you can:
 
ss.Execute(""Update Table1 Set gina  = Now()")


-- 
Stuart McLachlan
Lexacorp Ltd
Application Development,  IT Consultancy
http://www.lexacorp.com.pg



More information about the AccessD mailing list