Date last updated

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a wee problem that I hope someone can help me with, I have a module
that runs a set of queries to update a table what I would like to do is be
able to show on the switchborad the date that this was last run any
ideas/suggestions or even a piece of code would be greatly recieved.

TIA
 
Hi

I added this line

CurrentDb.Execute "INSERT INTO Planned Procurement (MyDate) SELECT Now() AS
LastUpdate;"

to my code assuming I needed to change Table1 and Expr1 to the relevant
names in my DB but on execute I get the following "Error 3134: Syntax error
in INSERT INTO statement"

Any Ideas?

TIA
 
souchie40 said:
Hi

I added this line

CurrentDb.Execute "INSERT INTO Planned Procurement (MyDate) SELECT
Now() AS LastUpdate;"

to my code assuming I needed to change Table1 and Expr1 to the
relevant names in my DB but on execute I get the following "Error
3134: Syntax error in INSERT INTO statement"

Any Ideas?

Table or field names that include spaces (bad idea) need to be surrounded with
square brackets. You also cannot use SELECT unless you are pulling your value
FROM a table or query. You need to use the VALUES clause instead.

CurrentDb.Execute "INSERT INTO [Planned Procurement] (MyDate) VALUES (Now())"
 
I agree with the brackets on spaces but try:

INSERT INTO Table1 ( MyDate ) SELECT Now() AS Expr1;

Works just fine either as a query or with CurrentDB.Execute.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

Rick Brandt said:
souchie40 said:
Hi

I added this line

CurrentDb.Execute "INSERT INTO Planned Procurement (MyDate) SELECT
Now() AS LastUpdate;"

to my code assuming I needed to change Table1 and Expr1 to the
relevant names in my DB but on execute I get the following "Error
3134: Syntax error in INSERT INTO statement"

Any Ideas?

Table or field names that include spaces (bad idea) need to be surrounded with
square brackets. You also cannot use SELECT unless you are pulling your value
FROM a table or query. You need to use the VALUES clause instead.

CurrentDb.Execute "INSERT INTO [Planned Procurement] (MyDate) VALUES (Now())"
 
Arvin said:
I agree with the brackets on spaces but try:

INSERT INTO Table1 ( MyDate ) SELECT Now() AS Expr1;

Works just fine either as a query or with CurrentDB.Execute.

Hmm, perhaps I'm thinking of SQL Server or UDB400 SQL syntax. I'm certain that
I've run into cases where SELECT had to be followed by FROM. It was probably
UDB400. I know with simple SELECT queries it will not allow you to select a
literal without specifying a FROM table like SQL Server does.
 
Hi,

Thanks guys that works a treat what I should of done was changed MyDate to
the field name. this gives it fot the table, what would I need to do for each
record, this is along the lines would be better for querying later but not
essential if to differcult.

MTIA

Arvin Meyer said:
I agree with the brackets on spaces but try:

INSERT INTO Table1 ( MyDate ) SELECT Now() AS Expr1;

Works just fine either as a query or with CurrentDB.Execute.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

Rick Brandt said:
souchie40 said:
Hi

I added this line

CurrentDb.Execute "INSERT INTO Planned Procurement (MyDate) SELECT
Now() AS LastUpdate;"

to my code assuming I needed to change Table1 and Expr1 to the
relevant names in my DB but on execute I get the following "Error
3134: Syntax error in INSERT INTO statement"

Any Ideas?

Table or field names that include spaces (bad idea) need to be surrounded with
square brackets. You also cannot use SELECT unless you are pulling your value
FROM a table or query. You need to use the VALUES clause instead.

CurrentDb.Execute "INSERT INTO [Planned Procurement] (MyDate) VALUES (Now())"
 

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