BlueJacket
Registered User.
- Local time
- Today, 05:17
- Joined
- Jan 11, 2017
- Messages
- 92
I'm trying to write some SQL code from VBA to populate a table. This is what I have so far:
It keeps giving me a syntax error. I've commented out sections of it to test it line by line and the main holdup seems to be happening around the joining table tblQuietTitle_PropertDetails between tblPropertyDetails and tblQuietTitle. What am I missing?
Side note, while doing this, I noticed there's a "y" missing in tblQuietTitle_PropertDetails. If I rename that table, will it mess up other queries/relationships? It doesn't appear in other VBA code.
Thanks in advance.
Code:
Private Sub butTest_Click()
Dim strSQL As String
Dim strTable As String
'clear tblSEoSMergeList
strTable = "tblSEoSMergeList"
strSQL = "DELETE tblSEoSMergeList.* FROM tblSEoSMergeList;"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
strSQL = ""
strSQL = strSQL & "INSERT INTO tblSEoSMergeList "
strSQL = strSQL & "SELECT [tblPropertyDetails]![StreetNumber] & "" "" & [tblPropertyDetails]![StreetName] AS Property, "
strSQL = strSQL & "tblClients.ClientName AS Client, "
strSQL = strSQL & "tblQuietTitle.CaseNumber, "
strSQL = strSQL & "tblPropertyDetails.CountyID AS County, "
strSQL = strSQL & "tblPropertyDetails.ParcelID AS Parcel, "
strSQL = strSQL & "DefList([Forms]![frmServiceChart]![CaseID]) AS DefList "
strSQL = strSQL & "FROM tblPropertyDetails "
strSQL = strSQL & "LEFT JOIN tblClients "
strSQL = strSQL & "ON tblPropertyDetails.ClientID = tblClients.ClientID "
strSQL = strSQL & "LEFT JOIN tblQuietTitle_PropertDetails "
strSQL = strSQL & "ON tblPropertyDetails.PropertyID = tblQuietTitle_PropertDetails.PropertyID "
strSQL = strSQL & "LEFT JOIN tblQuietTitle "
strSQL = strSQL & "ON tblQuietTitle_PropertDetails.CaseID = tblQuietTitle.CaseID "
strSQL = strSQL & "LEFT JOIN tblDefendantCaseManagement "
strSQL = strSQL & "ON tblQuietTitle.CaseID = tblDefendantCaseManagement.CaseID "
strSQL = strSQL & "WHERE tblQuietTitle.CaseID = [Forms]![frmServiceChart]![CaseID]"
strSQL = strSQL & ";"
Debug.Print strSQL
DoCmd.RunSQL strSQL
End Sub
It keeps giving me a syntax error. I've commented out sections of it to test it line by line and the main holdup seems to be happening around the joining table tblQuietTitle_PropertDetails between tblPropertyDetails and tblQuietTitle. What am I missing?
Side note, while doing this, I noticed there's a "y" missing in tblQuietTitle_PropertDetails. If I rename that table, will it mess up other queries/relationships? It doesn't appear in other VBA code.
Thanks in advance.