docmd.sendobject question

G

Guest

Is there a way to add criteria for the report in docmd.sendobject?

I need to add:

stCriteria = "[tblPI]![Pri_responsible] = """ &
[Forms]![frmReports]![txtRptTransfer] & """"

To:

DoCmd.SendObject acReport, stDocName, "Snapshot Format",
[lstReport].[Column](1)


Thanks in advance!!
 
A

Allen Browne

SendObject does not have a WhereCondition like OpenReport.

As a workaround, you can pass the filter via a public string variable, and
apply it in Report_Open event.

1. In a standard module (Modules tab of Database Window), in the General
Declarations section (top, with the Option statements), enter:
Public gstrReportFilter As String

2. In the code that calls SendObject:
gstrReportFilter = "[tblPI]![Pri_responsible] = """ & _
[Forms]![frmReports]![txtRptTransfer] & """"

3. In the Open event of the report:
If Len(gstrReportFilter) > 0 Then
Me.Filter = gstrReportFilter
Me.FilterOn = True
gstrReportFilter = vbNullString
End If
 
G

Guest

Allen,

Im not sure if I am putting the part 2 in the right place, here is my code:

Dim stDocName As String
Dim rptCount
rptCount = DCount("[Auto]", "tblPI", "status = 'Open' " _
& "And [UserName] = " & "'" & Me.txtUser & "'" _
& "And " & "[Pri_responsible] = '" & Me.txtRptTransfer & "'")

If IsNull(Me.lstReport) Then
MsgBox ("Please select Responsible personnel"), vbInformation
Else
If rptCount = 0 Then
MsgBox "The selected personnel does not have any issues assigned
by you that are currently open!", vbInformation
Else
stDocName = "rptOpen"
gstrReportFilter = "[tblPI]![Pri_responsible] = """ & _
[Forms]![frmReports]![txtRptTransfer] & """"
DoCmd.SendObject acReport, stDocName, "Snapshot Format",
[lstReport].[Column](1)
End If


Thank you very much for all your help.

Allen Browne said:
SendObject does not have a WhereCondition like OpenReport.

As a workaround, you can pass the filter via a public string variable, and
apply it in Report_Open event.

1. In a standard module (Modules tab of Database Window), in the General
Declarations section (top, with the Option statements), enter:
Public gstrReportFilter As String

2. In the code that calls SendObject:
gstrReportFilter = "[tblPI]![Pri_responsible] = """ & _
[Forms]![frmReports]![txtRptTransfer] & """"

3. In the Open event of the report:
If Len(gstrReportFilter) > 0 Then
Me.Filter = gstrReportFilter
Me.FilterOn = True
gstrReportFilter = vbNullString
End If

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

JAdams said:
Is there a way to add criteria for the report in docmd.sendobject?

I need to add:

stCriteria = "[tblPI]![Pri_responsible] = """ &
[Forms]![frmReports]![txtRptTransfer] & """"

To:

DoCmd.SendObject acReport, stDocName, "Snapshot Format",
[lstReport].[Column](1)


Thanks in advance!!
 

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

Similar Threads


Top