Solved

Problems with Quotes Syntax issues

Posted on 2013-05-29
5
285 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 70

Accepted Solution

by:
Qlemo earned 500 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

623 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