If blank report...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi:

I have a report based on a query with string parameter, e.g. [name]; if no
records associated with the name the report is blank; is there any way to get
a message in the report/ or on the screen that tells : 'no records for that
name'

Sometimes the report is blank because the name is misspelled...
Thanks,

Dan
 
Reports have a NoData event that you can use.

Here's a sample from the Help file:

Private Sub Report_NoData(Cancel As Integer)
MsgBox "The report has no data." & _
chr(13) & "Printing is canceled. " & _
chr(13) & "Check the data source for the " & _
chr(13) & "report. Make sure you entered " & _
chr(13) & "the correct criteria (for " & _
chr(13) & "example, a valid range of " & _
chr(13) & "dates),." vbOKOnly + vbInformation
Cancel = True
End Sub
 
Thank you! I will try.

Dan

Douglas J. Steele said:
Reports have a NoData event that you can use.

Here's a sample from the Help file:

Private Sub Report_NoData(Cancel As Integer)
MsgBox "The report has no data." & _
chr(13) & "Printing is canceled. " & _
chr(13) & "Check the data source for the " & _
chr(13) & "report. Make sure you entered " & _
chr(13) & "the correct criteria (for " & _
chr(13) & "example, a valid range of " & _
chr(13) & "dates),." vbOKOnly + vbInformation
Cancel = True
End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



D said:
Hi:

I have a report based on a query with string parameter, e.g. [name]; if no
records associated with the name the report is blank; is there any way to
get
a message in the report/ or on the screen that tells : 'no records for
that
name'

Sometimes the report is blank because the name is misspelled...
Thanks,

Dan
 
When I use the method indicated here, it works fine, but then Access displays
a message box stating "The OpenReport action was canceled". Is there any way
to suppress this?

Thanks, Stuart

Douglas J. Steele said:
Reports have a NoData event that you can use.

Here's a sample from the Help file:

Private Sub Report_NoData(Cancel As Integer)
MsgBox "The report has no data." & _
chr(13) & "Printing is canceled. " & _
chr(13) & "Check the data source for the " & _
chr(13) & "report. Make sure you entered " & _
chr(13) & "the correct criteria (for " & _
chr(13) & "example, a valid range of " & _
chr(13) & "dates),." vbOKOnly + vbInformation
Cancel = True
End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



D said:
Hi:

I have a report based on a query with string parameter, e.g. [name]; if no
records associated with the name the report is blank; is there any way to
get
a message in the report/ or on the screen that tells : 'no records for
that
name'

Sometimes the report is blank because the name is misspelled...
Thanks,

Dan
 
How are you opening the report? I'm on the road right now, so I can't check
my sample databases, but I seem to recall that if you're opening the report
programmatically, you can check for the error code in the calling routine.
Afraid I don't remember the Err.Number value in question. though.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Stuart said:
When I use the method indicated here, it works fine, but then Access
displays
a message box stating "The OpenReport action was canceled". Is there any
way
to suppress this?

Thanks, Stuart

Douglas J. Steele said:
Reports have a NoData event that you can use.

Here's a sample from the Help file:

Private Sub Report_NoData(Cancel As Integer)
MsgBox "The report has no data." & _
chr(13) & "Printing is canceled. " & _
chr(13) & "Check the data source for the " & _
chr(13) & "report. Make sure you entered " & _
chr(13) & "the correct criteria (for " & _
chr(13) & "example, a valid range of " & _
chr(13) & "dates),." vbOKOnly + vbInformation
Cancel = True
End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



D said:
Hi:

I have a report based on a query with string parameter, e.g. [name]; if
no
records associated with the name the report is blank; is there any way
to
get
a message in the report/ or on the screen that tells : 'no records for
that
name'

Sometimes the report is blank because the name is misspelled...
Thanks,

Dan
 
Doug, I am opening the report in code. For testing purposes I tried "On
Error Resume Next" and "On Error goto 0". Neither suppresses the message.
any ideas?

Thanks, Stuart

Douglas J. Steele said:
How are you opening the report? I'm on the road right now, so I can't check
my sample databases, but I seem to recall that if you're opening the report
programmatically, you can check for the error code in the calling routine.
Afraid I don't remember the Err.Number value in question. though.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Stuart said:
When I use the method indicated here, it works fine, but then Access
displays
a message box stating "The OpenReport action was canceled". Is there any
way
to suppress this?

Thanks, Stuart

Douglas J. Steele said:
Reports have a NoData event that you can use.

Here's a sample from the Help file:

Private Sub Report_NoData(Cancel As Integer)
MsgBox "The report has no data." & _
chr(13) & "Printing is canceled. " & _
chr(13) & "Check the data source for the " & _
chr(13) & "report. Make sure you entered " & _
chr(13) & "the correct criteria (for " & _
chr(13) & "example, a valid range of " & _
chr(13) & "dates),." vbOKOnly + vbInformation
Cancel = True
End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Hi:

I have a report based on a query with string parameter, e.g. [name]; if
no
records associated with the name the report is blank; is there any way
to
get
a message in the report/ or on the screen that tells : 'no records for
that
name'

Sometimes the report is blank because the name is misspelled...
Thanks,

Dan
 
Since Doug is on the road, I'll take a shot at this.
I assume your error message is coming from the code that opens the report.
If the opened report is closed/cancel with code in the report, this will
create error number 2501 in the code that opens the report. You can either
ignore all errors or trap and ignore err.Number = 2501.

If this doesn't work, make sure your options are not set to "Break On All
Errors".

--
Duane Hookom
MS Access MVP
--

Stuart said:
Doug, I am opening the report in code. For testing purposes I tried "On
Error Resume Next" and "On Error goto 0". Neither suppresses the message.
any ideas?

Thanks, Stuart

Douglas J. Steele said:
How are you opening the report? I'm on the road right now, so I can't
check
my sample databases, but I seem to recall that if you're opening the
report
programmatically, you can check for the error code in the calling
routine.
Afraid I don't remember the Err.Number value in question. though.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Stuart said:
When I use the method indicated here, it works fine, but then Access
displays
a message box stating "The OpenReport action was canceled". Is there
any
way
to suppress this?

Thanks, Stuart

:

Reports have a NoData event that you can use.

Here's a sample from the Help file:

Private Sub Report_NoData(Cancel As Integer)
MsgBox "The report has no data." & _
chr(13) & "Printing is canceled. " & _
chr(13) & "Check the data source for the " & _
chr(13) & "report. Make sure you entered " & _
chr(13) & "the correct criteria (for " & _
chr(13) & "example, a valid range of " & _
chr(13) & "dates),." vbOKOnly + vbInformation
Cancel = True
End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Hi:

I have a report based on a query with string parameter, e.g. [name];
if
no
records associated with the name the report is blank; is there any
way
to
get
a message in the report/ or on the screen that tells : 'no records
for
that
name'

Sometimes the report is blank because the name is misspelled...
Thanks,

Dan
 
Duane, that works. Thanks.

Duane Hookom said:
Since Doug is on the road, I'll take a shot at this.
I assume your error message is coming from the code that opens the report.
If the opened report is closed/cancel with code in the report, this will
create error number 2501 in the code that opens the report. You can either
ignore all errors or trap and ignore err.Number = 2501.

If this doesn't work, make sure your options are not set to "Break On All
Errors".

--
Duane Hookom
MS Access MVP
--

Stuart said:
Doug, I am opening the report in code. For testing purposes I tried "On
Error Resume Next" and "On Error goto 0". Neither suppresses the message.
any ideas?

Thanks, Stuart

Douglas J. Steele said:
How are you opening the report? I'm on the road right now, so I can't
check
my sample databases, but I seem to recall that if you're opening the
report
programmatically, you can check for the error code in the calling
routine.
Afraid I don't remember the Err.Number value in question. though.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



When I use the method indicated here, it works fine, but then Access
displays
a message box stating "The OpenReport action was canceled". Is there
any
way
to suppress this?

Thanks, Stuart

:

Reports have a NoData event that you can use.

Here's a sample from the Help file:

Private Sub Report_NoData(Cancel As Integer)
MsgBox "The report has no data." & _
chr(13) & "Printing is canceled. " & _
chr(13) & "Check the data source for the " & _
chr(13) & "report. Make sure you entered " & _
chr(13) & "the correct criteria (for " & _
chr(13) & "example, a valid range of " & _
chr(13) & "dates),." vbOKOnly + vbInformation
Cancel = True
End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Hi:

I have a report based on a query with string parameter, e.g. [name];
if
no
records associated with the name the report is blank; is there any
way
to
get
a message in the report/ or on the screen that tells : 'no records
for
that
name'

Sometimes the report is blank because the name is misspelled...
Thanks,

Dan
 
Thanks, Duane.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Duane Hookom said:
Since Doug is on the road, I'll take a shot at this.
I assume your error message is coming from the code that opens the report.
If the opened report is closed/cancel with code in the report, this will
create error number 2501 in the code that opens the report. You can either
ignore all errors or trap and ignore err.Number = 2501.

If this doesn't work, make sure your options are not set to "Break On All
Errors".

--
Duane Hookom
MS Access MVP
--

Stuart said:
Doug, I am opening the report in code. For testing purposes I tried "On
Error Resume Next" and "On Error goto 0". Neither suppresses the
message.
any ideas?

Thanks, Stuart

Douglas J. Steele said:
How are you opening the report? I'm on the road right now, so I can't
check
my sample databases, but I seem to recall that if you're opening the
report
programmatically, you can check for the error code in the calling
routine.
Afraid I don't remember the Err.Number value in question. though.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



When I use the method indicated here, it works fine, but then Access
displays
a message box stating "The OpenReport action was canceled". Is there
any
way
to suppress this?

Thanks, Stuart

:

Reports have a NoData event that you can use.

Here's a sample from the Help file:

Private Sub Report_NoData(Cancel As Integer)
MsgBox "The report has no data." & _
chr(13) & "Printing is canceled. " & _
chr(13) & "Check the data source for the " & _
chr(13) & "report. Make sure you entered " & _
chr(13) & "the correct criteria (for " & _
chr(13) & "example, a valid range of " & _
chr(13) & "dates),." vbOKOnly + vbInformation
Cancel = True
End Sub


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Hi:

I have a report based on a query with string parameter, e.g.
[name]; if
no
records associated with the name the report is blank; is there any
way
to
get
a message in the report/ or on the screen that tells : 'no records
for
that
name'

Sometimes the report is blank because the name is misspelled...
Thanks,

Dan
 
Back
Top