title: DAO passthrough query using VBA: "Error 3131 Syntax error in from clause"
body: <p>I copied a solution found in Stack Overflow, adapted it to my needs.</p>
  <pre class="lang-vb prettyprint-override"><code>Public Function getAssortmentTypes(Optional personId As Variant) As DAO.Recordset 'personId is integer
      Dim strQuery As String
      Dim qdf As DAO.QueryDef
      Dim rst As DAO.Recordset
      
      If IsMissing(personId) Then
          strQuery = &quot;SELECT assortment_type.type_id, assortment_type.type_name AS qryTest FROM assortment_type&quot;
      Else
          strQuery = &quot;SELECT * FROM get_non_deleted_assortment_types_by_user(&quot; &amp; personId &amp; &quot;)&quot;
      End If
          
      Set qdf = CurrentDb.CreateQueryDef(&quot;&quot;)
      With qdf
          .SQL = strQuery
          .Connect = getDBConnectionString
          .ReturnsRecords = True
      End With
      
      Set rst = qdf.OpenRecordset
      Debug.Print rst!qryTest
      Set getAssortmentTypes = rst
  End Function
  </code></pre>
  <p>In my postgresql db I do have a working function and appropriate tables. I've tested sql queries with DBEaver and they work.</p>
  <p>I'm receiving just one row (should be about 30) when I call the function without a parameter.</p>
  <p>With a parameter I expect filtered resultset but receive</p>
  <blockquote>
  <p>&quot;Error 3131 Syntax error in from clause&quot;.</p>
  </blockquote>