Stuart McLachlan
stuart at lexacorp.com.pg
Thu Oct 9 16:38:40 CDT 2003
Could be because of the table name. Date is a reserved word, that may
be screwing up the interpretation of the SQL string. Avoid using
reserved words for objects - it creates all sorts of problems.
On 9 Oct 2003 at 10:07, Oleg_123 at xuppa.com wrote:
> Thanks Stuart,
> this works goo, exsept I am still not able to update the table...
> With this line commented, it works
> DoCmd.RunSQL "Update Date Set ldate = Now()"
>
> Also, I'd like it to be performed on opening of the database. Is that
> possible ?
>
>
> Private Sub Command1_Click()
>
> last_time = DLookup("ldate", "Date")
> nnow = Now()
>
> andy = DateDiff("h", last_time, nnow)
>
> If andy > 14 Then
> DoCmd.SetWarnings False
> ' DoCmd.RunSQL "Update Date Set ldate = Now()"
> msgbox ("ok")
> DoCmd.SetWarnings True
> Else
> msgbox ("The function was already performed today")
> End If
>
> End Sub
>
>
>
> > 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
> >
> > _______________________________________________
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
>
>
>
> -----------------------------------------
> Get Breaking News from CNN, ABC, NBC, CBS Now.
> http://www.xuppa.com/news/?link=webmail
>
>
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
--
Lexacorp Ltd
http://www.lexacorp.com.pg
Information Technology Consultancy, Software Development,System Support.