docmd.openreport ?

G

Guest

I have a report which is rptOpen and would like the report to open up with
the records only for the field Pri_responsible. Normally, I would enter in
the query (qryOpenActions) under Pri_responsible the
[Forms]![frmReports]![txtRptTransfer]
but I need to leave it open to run other reports. Am I missing formatting?
Please help, code below:


Dim stdocName as string

stdocname = "rptOpen"

DoCmd.OpenReport stdocname, acPreview, [qryOpenActions],
[Pri_responsible] = [Forms]![frmReports]![txtRptTransfer]



Thanks!!!!
 
A

Allen Browne

Ignore the FilterConditon argument of OpeReport, and set up a string for the
WhereCondition:

Dim stDocName as String
Dim stCriteria As String

stdocname = "rptOpen"
stCriteria = "[Pri_responsible] = " & [Forms]![frmReports]![txtRptTransfer]
DoCmd.OpenReport stDocName, acViewPreview, , stCriteria


Note: if Pri_responsible is a Text type field (not a Number type field), you
need extra quotes:
stCriteria = "[Pri_responsible] = """ &
[Forms]![frmReports]![txtRptTransfer] & """"
 

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