<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Error 3061' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Error 3061' posted on the 'Access databases and VB' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Fri, 24 May 2013 20:13:15 -0700</pubDate>
    <lastBuildDate>Fri, 24 May 2013 20:13:15 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Error 3061</title>
      <link>http://www.programmersheaven.com/mb/AccessAndVB/430542/430542/error-3061/</link>
      <description>I have a module as an event to a form. It is designed to collect multiple customer_id from user and then run a report which outputs a PDF file for each customer_id.&lt;br /&gt;
I'm getting the error 3061 on the sql string. Here is the code:&lt;br /&gt;
Anybody know a solution? I searched all over for this and still no solution.&lt;br /&gt;
 &lt;br /&gt;
Sub Command21_Click()&lt;br /&gt;
 &lt;br /&gt;
 '------------------------------------------&lt;br /&gt;
'On Error GoTo Err_Handler&lt;br /&gt;
    'Purpose:  Open the report filtered to the items selected in the list box.&lt;br /&gt;
    'Author:   Allen J Browne, 2004.   &lt;a href="http://allenbrowne.com"&gt;http://allenbrowne.com&lt;/a&gt;&lt;br /&gt;
'----------------------------------------------&lt;br /&gt;
 'glbVarName As String&lt;br /&gt;
 Dim rs As DAO.Recordset&lt;br /&gt;
Dim sql As String&lt;br /&gt;
Dim strPath As String&lt;br /&gt;
TempVars.Add "strvndCode", Null 'Me.cboProdCode.Value&lt;br /&gt;
TempVars.Add "StartDate", Me.StartDate.Value&lt;br /&gt;
TempVars.Add "EndDate", Me.EndDate.Value&lt;br /&gt;
'-----------------------------------------------&lt;br /&gt;
    Dim varItem As Variant      'Selected items&lt;br /&gt;
    Dim strWhere As String      'String to use as WhereCondition&lt;br /&gt;
    Dim strDescrip As String    'Description of WhereCondition&lt;br /&gt;
    Dim lngLen As Long          'Length of string&lt;br /&gt;
    Dim strDelim As String      'Delimiter for this field type.&lt;br /&gt;
    Dim strDoc As String        'Name of report to open.&lt;br /&gt;
strDelim = """"            'Delimiter appropriate to field type. See note 1.&lt;br /&gt;
    strDoc = "test pdf"&lt;br /&gt;
'MsgBox strDoc&lt;br /&gt;
    'Loop through the ItemsSelected in the list box.&lt;br /&gt;
    With Me.NamesList     'LstCategory&lt;br /&gt;
        For Each varItem In .ItemsSelected&lt;br /&gt;
            If Not IsNull(varItem) Then&lt;br /&gt;
                'Build up the filter from the bound column (hidden).&lt;br /&gt;
               ' strWhere = strWhere &amp;amp; strDelim &amp;amp; .ItemData(varItem) &amp;amp; strDelim &amp;amp; ","&lt;br /&gt;
                strWhere = strWhere &amp;amp; .ItemData(varItem) &amp;amp; ","&lt;br /&gt;
                'Build up the description from the text in the visible column. See note 2.&lt;br /&gt;
                strDescrip = strDescrip &amp;amp; """" &amp;amp; .Column(1, varItem) &amp;amp; """, "&lt;br /&gt;
            End If&lt;br /&gt;
        Next&lt;br /&gt;
    End With&lt;br /&gt;
    &lt;br /&gt;
    'Remove trailing comma. Add field name, IN operator, and brackets.&lt;br /&gt;
    lngLen = Len(strWhere) - 1&lt;br /&gt;
    If lngLen &amp;gt; 0 Then&lt;br /&gt;
        strWhere = "[Customer_ID] IN (" &amp;amp; Left$(strWhere, lngLen) &amp;amp; ")"&lt;br /&gt;
        lngLen = Len(strDescrip) - 2&lt;br /&gt;
        If lngLen &amp;gt; 0 Then&lt;br /&gt;
            strDescrip = "Categories: " &amp;amp; Left$(strDescrip, lngLen)&lt;br /&gt;
        End If&lt;br /&gt;
    End If&lt;br /&gt;
    &lt;br /&gt;
    'Report will not filter if open, so close it. For Access 97, see note 3.&lt;br /&gt;
    If CurrentProject.AllReports(strDoc).IsLoaded Then&lt;br /&gt;
        DoCmd.Close acReport, strDoc&lt;br /&gt;
    End If&lt;br /&gt;
    strPath = "C:\Access\"&lt;br /&gt;
sql = "SELECT DISTINCT TempTablePDF.Customer_id FROM TempTablePDF where '" &amp;amp; strWhere &amp;amp; "' and invoice_date between '#startdate#' and '#enddate#';"[/color]Set rs = CurrentDb().OpenRecordset(sql, dbOpenSnapshot)&lt;br /&gt;
Do While Not rs.EOF&lt;br /&gt;
strVndCode = rs!Customer_id&lt;br /&gt;
TempVars.Add "strvndCode", strVndCode&lt;br /&gt;
  OpenArgs:=strDescrip&lt;br /&gt;
&lt;br /&gt;
DoCmd.OutputTo acOutputReport, strDoc, acFormatPDF, strPath &amp;amp; strVndCode &amp;amp; ".pdf"&lt;br /&gt;
rs.MoveNext&lt;br /&gt;
Loop&lt;br /&gt;
&lt;br /&gt;
Set rs = Nothing&lt;br /&gt;
End Sub&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/AccessAndVB/430542/430542/error-3061/</guid>
      <pubDate>Wed, 05 Dec 2012 20:57:26 -0700</pubDate>
      <category>Access databases and VB</category>
    </item>
  </channel>
</rss>