Run-Time Error 3131 Syntax error in FROM clause

m_sami9

New member
Local time
Today, 19:37
Joined
Feb 2, 2020
Messages
13
I'm facing problem about Run-Time Error 3131 Syntax error in FROM clause.

Please help me to resolve the problem.

Code:
    CurrentDb.Execute " INSERT INTO tblTestReport (TestDetailID, TestID, ReceiptID, ParticularsID, PARTICULARS, RESULT, UNITS, MALE, FEMALE, ABNORMAL, PartHead, PartHeadID) " _
        & " SELECT TestDetailID, TestID, ReceiptID, ParticularsID, PARTICULARS, RESULT, UNITS, MALE, FEMALE, ABNORMAL, PartHead, PartHeadID " _
        & " FROM tblSampleReceipts2 (tblTestDesc INNER JOIN tblTestParticulars ON tblTestDesc.TestID = tblTestParticulars.TestID) INNER JOIN tblTestDetails2 ON tblTestDesc.TestID = tblTestDetails2.TestID WHERE ReceiptID = '" & ReceiptID & "'"
 
Put the SQL into a string variable and debug.print it in the immediate window.
Get into the habit of doing this for all but the simplest constructions of SQL strings.

Then paste it into the query editor, it should highlight what it can't work out.
 
Hi,

tblSampleReceipts2 is not correctly joined - it has no JOIN clause or ON clause.

Does it need to be there at all?

If it does need to be included, then re-create the SELECT portion of the query in the query designer and copy the SQL here, and we can help you get it into a string variable
 
Hi,

tblSampleReceipts2 is not correctly joined - it has no JOIN clause or ON clause.

Does it need to be there at all?

If it does need to be included, then re-create the SELECT portion of the query in the query designer and copy the SQL here, and we can help you get it into a string variable
Code:
    CurrentDb.Execute "INSERT INTO tblTestReport ( TestDetailID, TestID, ReceiptID, ParticularsID, PARTICULARS, RESULT, UNITS, MALE, FEMALE, ABNORMAL, PartHead, PartHeadID ) " _
        & " SELECT tblTestDetails2.TestDetailID, tblTestDetails2.TestID, tblTestDetails2.ReceiptID, tblTestParticulars.ParticularsID, tblTestParticulars.PARTICULARS, tblTestParticulars.RESULT, tblTestParticulars.UNITS, tblTestParticulars.MALE, tblTestParticulars.FEMALE, tblTestParticulars.ABNORMAL, tblTestParticulars.PartHead, tblTestParticulars.PartHeadID " _
        & " FROM tblSampleReceipts2, (tblTestDesc INNER JOIN tblTestParticulars ON tblTestDesc.TestID = tblTestParticulars.TestID) INNER JOIN tblTestDetails2 ON tblTestDesc.TestID = tblTestDetails2.TestID " _
        & " WHERE ReceiptID =  " & ReceiptID & " ;"
 
Adding the comma might fix your query, but will it give you the result you want - it will create a cartesian product (but will be limited by the WHERE clause).

Since we have no idea of your tables and their structure it's impossible to comment.

Have you got the result you want now?
 
Adding the comma might fix your query, but will it give you the result you want - it will create a cartesian product (but will be limited by the WHERE clause).

Since we have no idea of your tables and their structure it's impossible to comment.

Have you got the result you want now?
 

Attachments

  • Capture1.PNG
    Capture1.PNG
    29.5 KB · Views: 84
Can you create your APPEND query using the query designer? If you can, you can either execute that query or take its SQL and paste it in your code.
 

Users who are viewing this thread

Back
Top Bottom