Solved

Problems with Quotes Syntax issues

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

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Dlookup MSACCESS 5 25
Query Syntax 17 36
VB.net and sql server 4 36
How to use a single FE file for users with different access versions? 8 20
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 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