Solved

Problems with Quotes Syntax issues

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

930 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

13 Experts available now in Live!

Get 1:1 Help Now