DoCmd Close Report

K

kirstie adam

Can someone give me the code for closing the current report that is open?
(report is called [rpt all deliveries this week])

I had

DoCmd.Close acreport, "rpt all deliveries this week"

but it keeps asking me to debug

Thanks,
 
K

kirstie adam

No, am just using quotation marks.
I have pasted the whole thing below:

Private Sub Report_NoData(Cancel As Integer)
MsgBox "THERE ARE CURRENTLY NO SITES PROGRAMMED - THIS REPORT WILL NOW
CLOSE", vbInformation, "NO PROGRAMMED SITES"
DoCmd.close acReport, "rpt deliveries this week", acSaveNo
End Sub

Basically, if the report has no records in it, i want it to display a
message box then close automatically.

It just keeps highlighting the docmd line of code in yellow and asking me to
debug - but i don't know what i am doing wrong.

Any thoughts?

Kirstie


Andy Hull said:
Hi Kirstie

Your code is correct - it works fine for me.

The only thing I can think of checking at the moment is, have you put the
report name in your code in quotations or square brackets?

I only ask this because in your question you first use square brackets and
when you write your code you use quotations.

Square brackets will give an error (and ask you to debug). Quotations work.

Regards
Andy Hull


kirstie adam said:
Can someone give me the code for closing the current report that is open?
(report is called [rpt all deliveries this week])

I had

DoCmd.Close acreport, "rpt all deliveries this week"

but it keeps asking me to debug

Thanks,
 
F

fredg

No, am just using quotation marks.
I have pasted the whole thing below:

Private Sub Report_NoData(Cancel As Integer)
MsgBox "THERE ARE CURRENTLY NO SITES PROGRAMMED - THIS REPORT WILL NOW
CLOSE", vbInformation, "NO PROGRAMMED SITES"
DoCmd.close acReport, "rpt deliveries this week", acSaveNo
End Sub

Basically, if the report has no records in it, i want it to display a
message box then close automatically.

It just keeps highlighting the docmd line of code in yellow and asking me to
debug - but i don't know what i am doing wrong.

Any thoughts?

Kirstie

Andy Hull said:
Hi Kirstie

Your code is correct - it works fine for me.

The only thing I can think of checking at the moment is, have you put the
report name in your code in quotations or square brackets?

I only ask this because in your question you first use square brackets and
when you write your code you use quotations.

Square brackets will give an error (and ask you to debug). Quotations work.

Regards
Andy Hull


kirstie adam said:
Can someone give me the code for closing the current report that is open?
(report is called [rpt all deliveries this week])

I had

DoCmd.Close acreport, "rpt all deliveries this week"

but it keeps asking me to debug

Thanks,


Private Sub Report_NoData(Cancel As Integer)
MsgBox "THERE ARE CURRENTLY NO SITES PROGRAMMED - THIS REPORT WILL
NOW CLOSE", vbInformation, "NO PROGRAMMED SITES"
Cancel = True
End Sub
 

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