Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run time error 2585 action cn be carried out processing a form

Status
Not open for further replies.

axslearnr

Technical User
Apr 1, 2004
78
US
Hi
I am getting an error " Run-time error 2585 This action cant be carried out while processing a form or report event"

I have a form where i run a report when i press the command button. i have written code when there is no data in the report. I get the error at on DoCmd.Close acReport line asking me to debug it. Earlier I didnt get this error now i am getting this run time error.

Private Sub Report_Analyst1_NoData(Cancel As Integer)
MsgBox "There are no records for this Sample Number!"
DoCmd.Close acReport
Cancel = True
End Sub

Private Sub Report_Page()
Me.Line (0, 0)-(Me.ScaleWidth, Me.ScaleHeight), , B
End Sub




Please let me know what could be the problem.

 
Hi!

What happens if you drop the docmd.close line?

The Cancel = True cancels the opening, so the close line isn't needed.

Roy-Vidar
 
Hi
thank you for ur reply. But it opens the report if i dont write Docmd.close acreport. withount nothing in it. i want to display a message and close it. even then i get that run time error.

pls let me know
 
Then there is probably something else wrong.

The syntax:

[tt]Private Sub SomeReport_NoData(Cancel As Integer)
MsgBox "blah!"
Cancel = True
End Sub[/tt]

Is the syntax used to cancel the opening of reports without data. Remove the close line, and try commenting out all other code in the report (especially the OnPage code), compile and see what happens.

You'd normally get a 2501, cancelled... by this, but not 2585

Roy-Vidar
 
hI
Thank you for very much . i appreciate it. I tried using ur code ir worked thanks. But I have an message when there is no selection the combobos where i select he tem and press the command button to review the report. even when the reoprt is cancelled bcos of no data it gives me both the messages.

so when there r no record to displays it gives me the no records in this message and and also the enter client name message since it is is the cmdclient error .

what do do to get only message?

Private Sub cmdClient_Report_Click()
On Error GoTo Err_cmdClient_Report_Click

Dim stDocName As String

stDocName = "OOSClientNames"

DoCmd.OpenReport ReportName:=stDocName, View:=acPreview, Wherecondition:="OOS.Client_ID1 = " & cmbClient_ID.Column(0) & " or OOS.Client_ID2= " & cmbClient_ID.Column(0) & " "
Me!cmbClient_ID = ""

Exit_cmdClient_Report_Click:
Exit Sub

Err_cmdClient_Report_Click:
MsgBox "Please Enter the Client Name!"

Resume Exit_cmdClient_Report_Click

End Sub
 
Hi again!

"Roughly" typed, I might have done something like this, involving:
1 - testing the combos for values, and assigning to a "where" variable, prior to opening the report
2 - using the errorhandler to handle the error (just skipping the message if 2501)

- you'll perhaps consider opening the report at all, if the combo is null?
- I've been assuming that the combos first column, is also the bound column, therefore dropped of the .Column(0), which you'll have to apply, if the first column is not the bound column

[tt]Private Sub cmdClient_Report_Click()
On Error GoTo Err_cmdClient_Report_Click
Dim stDocName As String
dim strWhere as string
stDocName = "OOSClientNames"
if len(trim$(me!cmblient_id) & vbnullstring)>0 then
strWhere = "OOS.Client_ID1 = " & Me!cmbClient_ID & _
" or OOS.Client_ID2= " & Me!cmbClient_ID
end if
DoCmd.OpenReport ReportName:=stDocName, View:=acPreview, Wherecondition:=strWhere
Me!cmbClient_ID = vbnullstring
Exit_cmdClient_Report_Click:
Exit Sub
Err_cmdClient_Report_Click:
if err.number<>2501 then
msgbox err.description
endif
Resume Exit_cmdClient_Report_Click
End Sub[/tt]

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top