Insert INTO Query

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

Guest

I am trying to add the below SQL Query into VB. It seems to fall down on the
"Where" definition.

Can anyone see where I've gone wrong?

Function AppendCpartyYesterday()

CurrentDb.Execute "INSERT INTO tblCpartyYesterday ( Oid, Adt, DateID, Id,
Type, Name, ShortName, Deleted )" & _
"SELECT Cparty_Audit.Oid, Cparty_Audit.Adt, Left(Cparty_Audit!Adt,2) AS
DateID, Cparty_Audit.Id, Cparty_Audit.Type, Cparty_Audit.Name,
Cparty_Audit.ShortName, Cparty_Audit.Deleted " & _
"FROM Cparty_Audit" & _
"WHERE (((Cparty_Audit.Adt)>Date()-1)) "

End Function
 
hi,
I am trying to add the below SQL Query into VB. It seems to fall down on the
"Where" definition.
Why do you assume this?
Can anyone see where I've gone wrong?
Use an error handler and

CurrentDb.Execute SQL, dbFailOnError

to get a concrete error.
Function AppendCpartyYesterday()

CurrentDb.Execute "INSERT INTO tblCpartyYesterday ( Oid, Adt, DateID, Id,
Type, Name, ShortName, Deleted )" & _
"SELECT Cparty_Audit.Oid, Cparty_Audit.Adt, Left(Cparty_Audit!Adt,2) AS
DateID, Cparty_Audit.Id, Cparty_Audit.Type, Cparty_Audit.Name,
Cparty_Audit.ShortName, Cparty_Audit.Deleted " & _
"FROM Cparty_Audit" & _
"WHERE (((Cparty_Audit.Adt)>Date()-1)) "

End Function

Type and Name are reserved words. Enclose them in square brackets (e.g.
[Type]).

The WHERE condition looks good.


mfG
--> stefan <--
 
You're missing a space between the table name in the FROM clause and the
keyword WHERE.

(And make the other changes Stefan suggested)
 
Back
Top