Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Problems with Quotes Syntax issues

Posted on 2013-05-29
5
Medium Priority
?
286 Views
Last Modified: 2013-05-29
Need to another pair of eyes to help me with this update stateement within my VBA Code:

curDB.Execute ("Update tblReportList_DistLst" & _
                " SET DistributionList = DConcat('DistList','TblReportDist', '[Name] = ''' & tblReportList_DistLst.Name & ''')" & _
                " WHERE tblReportList_DistLst.DistributionList Is Null")

Open in new window

0
Comment
Question by:Karen Schaefer
[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
5 Comments
 
LVL 23

Expert Comment

by:nemws1
ID: 39206040
I think you want this: (missing double quotes before and after tblReportList_DistLst.Name)

curDB.Execute ("Update tblReportList_DistLst" & _
                " SET DistributionList = DConcat('DistList','TblReportDist', '[Name] = '''" & tblReportList_DistLst.Name & "''')" & _
                " WHERE tblReportList_DistLst.DistributionList Is Null")
                                  

Open in new window

0
 
LVL 71

Accepted Solution

by:
Qlemo earned 2000 total points
ID: 39206126
There is also one single quotes too many:
curDB.Execute ("Update tblReportList_DistLst" & _
                " SET DistributionList = DConcat('DistList','TblReportDist', '[Name] = ''" & tblReportList_DistLst.Name & "'' ')" & _
                " WHERE tblReportList_DistLst.DistributionList Is Null")

Open in new window

0
 

Author Comment

by:Karen Schaefer
ID: 39206137
now I am getting variable not define on the '[Name] = ''" & tblReportList_DistLst.Name & "'' ')"
0
 

Author Comment

by:Karen Schaefer
ID: 39206151
Lets try a different approach - I am appending a table from the VBA Sql string, then I need to update the Concatenated Email address per each ReportName (Name)

Here is my code as far:

Need help with the Update statement using the correct tables and fields. based on the previous sql string.

Public Function ConcatDistList()
Dim curDB As DAO.Database
Dim strSQL As String, strSQL1 As String
Dim rs As DAO.Recordset, rs1 As DAO.Recordset
Dim MyString As String
   On Error GoTo ConcatDistList_Error

Set curDB = CurrentDb()

curDB.Execute ("Delete * from tblReportLIst_DistLst")

strSQL = "INSERT INTO tblReportList_DistLst ( Name, Type, Period, Special," & _
        " RunDate, [Day], JobName, [Number], [Order], UpdateDate, RunTime, Priority, SaveToHistory," & _
        " Owner, ManualTask )" & _
        " SELECT tblDailyLog.Name, tblDailyLog.Type, tblDailyLog.Period," & _
        " tblDailyLog.Special, tblDailyLog.RunDate, tblDailyLog.Day, tblDailyLog.JobName, tblDailyLog.Number," & _
        " tblDailyLog.Order, tblDailyLog.UpdateDate, tblDailyLog.RunTime, tblDailyLog.Priority," & _
        " tblDailyLog.SaveToHistory, tblDailyLog.Owner, tblDailyLog.ManualTask" & _
        " FROM tblDailyLog INNER JOIN tblReportDist ON tblDailyLog.Name = tblReportDist.RptName" & _
        " GROUP BY tblDailyLog.Name, tblDailyLog.Type, tblDailyLog.Period," & _
        " tblDailyLog.Special, tblDailyLog.RunDate, tblDailyLog.Day, tblDailyLog.JobName, tblDailyLog.Number," & _
        " tblDailyLog.Order, tblDailyLog.UpdateDate, tblDailyLog.RunTime, tblDailyLog.Priority," & _
        " tblDailyLog.SaveToHistory, tblDailyLog.Owner, tblDailyLog.ManualTask" & _
        " HAVING (((tblDailyLog.Period) <> 'Discontinued'))" & _
        " ORDER BY tblDailyLog.Name, tblDailyLog.Period"
curDB.Execute (strSQL)
 
curDB.Execute ("Update tblReportList_DistLst" & _
                " SET DistributionList = DConcat('DistList','TblReportDist', '[RptName] = ''" & [tblReportList].[Name] & "'' ')" & _
                " WHERE tblReportList_DistLst.DistributionList Is Null")
Debug.Print strSQL
curDB.Execute (strSQL)
DoCmd.OpenTable "tblReportLIst_DistLst", acViewNormal, acReadOnly
   On Error GoTo 0
   Exit Function

ConcatDistList_Error:

    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure ConcatDistList of Module _modDConcat"

End Function

Open in new window

0
 

Author Closing Comment

by:Karen Schaefer
ID: 39206368
Partial solution - see:  http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_28138761.html for full solution.

Thanks for the assistances
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
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…

722 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