Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / December 2006

Tip: Looking for answers? Try searching our database.

Insert INTO Query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Whelan - 06 Dec 2006 12:17 GMT
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
Stefan Hoffmann - 06 Dec 2006 12:31 GMT
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()
>
[quoted text clipped - 7 lines]
>
> End Function

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

The WHERE condition looks good.

mfG
--> stefan <--
Douglas J. Steele - 06 Dec 2006 13:12 GMT
You're missing a space between the table name in the FROM clause and the
keyword WHERE.

(And make the other changes Stefan suggested)

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

>I am trying to add the below SQL Query into VB. It seems to fall down on
>the
[quoted text clipped - 13 lines]
>
> End Function
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.