David-
Try this:
strSQL = "INSERT INTO tblServiceReportDetails (ServiceReportID, SamplePointID, ParameterID) " & _
"SELECT " & Me.ServiceReportID & ", SamplePointID, ParameterID " & _
"FROM tblServiceTemplates " & _
"INNER JOIN tblServiceTemplateDetails " & _
"ON tblServiceTemplates.ServiceTemplateID = tblServiceTemplateDetails.ServiceTemplateID " & _
"WHERE tblServiceTemplates.ServiceTemplateID = " & Me.ServiceTemplateID
"SELECT " & Me.ServiceReportID & ", SamplePointID, ParameterID " & _
"FROM tblServiceTemplates " & _
"INNER JOIN tblServiceTemplateDetails " & _
"ON tblServiceTemplates.ServiceTemplateID = tblServiceTemplateDetails.ServiceTemplateID " & _
"WHERE tblServiceTemplates.ServiceTemplateID = " & Me.ServiceTemplateID
John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
(Paris, France)
On Dec 12, 2016, at 11:04 PM, david.pratt@outlook.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
John, I am trying to get the templates to work using the SQL code you provided and I am really struggling (hours). Since the combination key of CustomerID and EquipmentID is not unique I didn't see how the SQL could work when there was more than one template for Customer/Equipment. So, to make it easier and better, I placed another field in tblServiceReports - ServiceTemplateID. So now, each time that a new service report record is created, the user has to select the template which it is based upon.
Here is the strSQL that I am putting into the AfterUpdate procedure:
strSQL = "INSERT INTO tblServiceReportDetails (ServiceReportID, SamplePointID, ParameterID)" & _
"SELECT Me.ServiceReportID,SamplePointID,ParameterID" & _
"FROM tblServiceTemplates" & _
"INNER JOIN tblServiceTemplateDetails" & _
"ON tblServiceTemplates.ServiceTemplateID = tblServiceTemplateDetails.ServiceTemplateID" & _
"WHERE tblServiceTemplates.ServiceTemplateID = Me.ServiceTemplateID"
"SELECT Me.ServiceReportID,SamplePointID,ParameterID" & _
"FROM tblServiceTemplates" & _
"INNER JOIN tblServiceTemplateDetails" & _
"ON tblServiceTemplates.ServiceTemplateID = tblServiceTemplateDetails.ServiceTemplateID" & _
"WHERE tblServiceTemplates.ServiceTemplateID = Me.ServiceTemplateID"
When I try to compile, the error "Syntax Error" appears and the entire block of code above is highlighted. Sometimes the INTO keyword is highlighted and the error "expected end of statement" shows up.
I have spent hours and don't know how to correct it.
Thank you, David
__._,_.___
Posted by: John Viescas <johnv@msn.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (22) |
Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.
.
__,_._,___
Tidak ada komentar:
Posting Komentar