Solved

Access VBA SQL Syntax Error for Line continuation

Posted on 2015-02-20
6
129 Views
Last Modified: 2016-02-10
I made the following DSum Update query in the editor and pasted into VBA using the   " &  _   for line continuation. Code turns red.  Tried two different blocks as below. Only the third line in the first block below turns red. Can I use DSUM in VBA like this?

strSQL7 = strSQL7 & " UPDATE tblRateCharges INNER JOIN tblRate ON"
strSQL7 = strSQL7 & " tblRateCharges.RateID = tblRate.RateID SET"
strSQL7 = strSQL7 & " tblRate.AddlFuelChargeable = DSum("Charge","tblRateCharges","FuelChargeable= -1")"    

strSQL7 = "UPDATE tblRateCharges INNER JOIN tblRate ON " & _
        "tblRateCharges.RateID = tblRate.RateID SET " & _
        "tblRate.AddlFuelChargeable = DSum("Charge","tblRateCharges","FuelChargeable= True")"
0
Comment
Question by:ExpressMan1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 19

Accepted Solution

by:
Eric Sherman earned 500 total points
ID: 40621647
Try this ...

strSQL7 = strSQL7 & " tblRate.AddlFuelChargeable = " & DSum("Charge","tblRateCharges","FuelChargeable= -1")  

ET
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 40621713
strSQL7 = strSQL7 & " tblRate.AddlFuelChargeable = DSum(""Charge"",""tblRateCharges"",""FuelChargeable= -1"")"     

Open in new window

You have to double each double quote being inside the string.
0
 

Author Closing Comment

by:ExpressMan1
ID: 40621723
Perfect! No longer red.  Thank You.
0
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
LVL 70

Expert Comment

by:Qlemo
ID: 40621731
But still wrong, probably. Do you want to insert the evaluated DSum into the UPDATE, or let the UPDATE do the calculation?
0
 

Author Comment

by:ExpressMan1
ID: 40621799
Let the UPDATE do the calculation.  The field tblRate.AddlFuelChargeable is updating as planned.

Thanks to both of you.
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 40621837
http:#a40621647 calculates the value, then adds it as a literal. But if it works for you ...
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question