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 / November 2006

Tip: Looking for answers? Try searching our database.

VBA SQL help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mattc66 - 17 Nov 2006 23:35 GMT
I am trying to run the below SQL statement in code. VBA doesn't like it. I am
trying to wrap the text as well. I have searched help on wraping of text and
I find the below is one method. I am not sure.

Could anyone help? Thanks Matt

DoCmd.RunSQL "UPDATE tblOrderDetails LEFT JOIN tblDiscMatrix & _
ON (tblOrderDetails.AR_Matrix = tblDiscMatrix.AR_Matrix) & _
AND (tblOrderDetails.AR_Code = tblDiscMatrix.AR_Code) & _
SET tblOrderDetails.Multiply = [tblDiscMatrix].[Discount]
WHERE tblOrderDetails.QuoteID = QuoteID; """

Signature

Matt Campbell
mattc (at) saunatec [dot] com

Douglas J. Steele - 18 Nov 2006 03:42 GMT
You need to terminate each string before you continue to another line:

DoCmd.RunSQL "UPDATE tblOrderDetails LEFT JOIN tblDiscMatrix " & _
"ON (tblOrderDetails.AR_Matrix = tblDiscMatrix.AR_Matrix) " & _
"AND (tblOrderDetails.AR_Code = tblDiscMatrix.AR_Code) "& _
"SET tblOrderDetails.Multiply = [tblDiscMatrix].[Discount] " & _
"WHERE tblOrderDetails.QuoteID = QuoteID"

What's QuoteID, btw? If it's a variable, it needs to go outside the quotes:
that last line would be either

"WHERE tblOrderDetails.QuoteID = " & QuoteID

if QuoteID is numeric, or

"WHERE tblOrderDetails.QuoteID = '" & QuoteID & "'"

if it's text.

Signature

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

>I am trying to run the below SQL statement in code. VBA doesn't like it. I
>am
[quoted text clipped - 9 lines]
> SET tblOrderDetails.Multiply = [tblDiscMatrix].[Discount]
> WHERE tblOrderDetails.QuoteID = QuoteID; """
 
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.