Solved

Problems with Quotes Syntax issues

Posted on 2013-05-29
5
264 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
  • 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 68

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now