Printing separate reports

  • Thread starter turks67 via AccessMonster.com
  • Start date
T

turks67 via AccessMonster.com

Someone was nice to put this code out there. The code works but I need to
print by month also.
In the query field i'm trying to filter the month using a combo box on a form
with forms!frmexceptprint!combo1. I the error msg is: too few parameters
expected 1.

Can someone help?



Private Sub cmd_Report_Click

Dim strSQL as string, strCriteria as string
Dim rs as DAO.Recordset

strSQL = "SELECT DISTINCT CustomerID FROM qry_Reports"
set rs = currentdb.openrecordset(strSQL,,dbfailonerror)

'loop through all of the customers
While not rs.eof

'this assumes you want to print the report
strCriteria = "CustomerID = " & rs("CustomerID")
docmd.OpenReport "reportname",acViewNormal,, strCriteria

rs.movenext
Wend
rs.close
set rs = nothing

End sub
 
P

pietlinden

Someone was nice to put this code out there. The code works but I need to
print by month also.
In the query field i'm trying to filter the month using a combo box on a form
with forms!frmexceptprint!combo1. I the error msg is: too few parameters
expected 1.

Can someone help?


Private Sub cmd_Report_Click

   Dim strSQL as string, strCriteria as string
   Dim rs as DAO.Recordset
Dim intMonth As Integer '<=== add this

intMonth = Me.cboPickAMonth <=== choose the value for the
month in your display before running this..
  strSQL = "SELECT DISTINCT CustomerID FROM qry_Reports"
  set rs = currentdb.openrecordset(strSQL)

  'loop through all of the customers
  While not rs.eof

      'this assumes you want to print the report
' Add the month to your criteria string....
      strCriteria = "CustomerID = " & rs("CustomerID") & " AND Month([SomeDateInReportRecordsource]) = intMonth
      docmd.OpenReport "reportname",acViewNormal,, strCriteria

      rs.movenext
  Wend
   rs.close
   set rs = nothing

End sub
 
T

turks67 via AccessMonster.com

The month is formatted as December 09 or January 10. etc

Someone was nice to put this code out there. The code works but I need to
print by month also.
[quoted text clipped - 3 lines]
Can someone help?
Private Sub cmd_Report_Click

   Dim strSQL as string, strCriteria as string
   Dim rs as DAO.Recordset
Dim intMonth As Integer '<=== add this

intMonth = Me.cboPickAMonth <=== choose the value for the
month in your display before running this..
  strSQL = "SELECT DISTINCT CustomerID FROM qry_Reports"
  set rs = currentdb.openrecordset(strSQL)
[quoted text clipped - 3 lines]
      'this assumes you want to print the report
' Add the month to your criteria string....
      strCriteria = "CustomerID = " & rs("CustomerID") & " AND Month([SomeDateInReportRecordsource]) = intMonth
      docmd.OpenReport "reportname",acViewNormal,, strCriteria
[quoted text clipped - 5 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top