Access 2003 On no data and Report display problem

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

Guest

I have a report a user can select from a menu and input a word/words to
search for.
I am looking for a clean routine in the event of No Data.
Right Now I have the On No Data Property set to run a macro that displays a
message box that no data was found, but then the user has to close that box,
and the next box which says The Open Report Action was canceled to get back
to the menu.

My next problem is the report itself which displays if there is data - there
are only 4 data elements on the report and I'm looking for a simple small way
to display this data.

Right now I have it doing a print preview of the report which the user has
to click on to get a better view of the data. Usually there are only a few
lines of data. Then the user has to click to close the report., or print it.

Can you display report data onscreen without using print preview?
 
FrankSpokane said:
I have a report a user can select from a menu and input a word/words to
search for.
I am looking for a clean routine in the event of No Data.

Ok, can I assume that he custom menu option runs some code, or perhaps runs
a Prompt form that allows the user to input some words, and then the code
launches the report?

Most of my custom menu code does in fact call code that can prompt for date
ranges etc, and then the code launches the report.

Since the cancel in the report means the report was canceled, you simply
trap the error, or even better..simply ignore it. You can go:

on error resume next
docmd.OpenReport "my cool report",acViewPreview,,strwhere

The above assumes you already built the strWhere from the prompts. I have a
screen shots of prompt screens here to give you some ideas of what I mean by
"prompt" screens
My next problem is the report itself which displays if there is data -
there
are only 4 data elements on the report and I'm looking for a simple small
way
to display this data.

Right now I have it doing a print preview of the report which the user has
to click on to get a better view of the data. Usually there are only a few
lines of data. Then the user has to click to close the report., or print
it.

Try my multi-select example here...and send only 2, or 3 records to the
report. I think it works just fine......(the trick is to put a
docmd.maximize in the reports on-open event. Try the multi-select example
here:

http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html
 
Hi Albert

I am using a standard Access Menu with a button on the menu the user clicks
to look up data.
;---Onclick code
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

Dim stDocName As String

stDocName = "Areacodes"
DoCmd.OpenReport stDocName, acPreview

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub
;--- end code

The report is named Areacodes, which is based on the Areacodes Query
I have the Report On Nodata set to run a macro Nodata which displays the
message box which works, but I keep getting the Open Report Action Was
Canceled Box after I click to close the macro.

I tried using your code for this routine but there is something different I
am doing that makes it not work from your logical method.

Based on this info can you tell me what I need to change? I do need to keep
my menu with all the user choice buttons, and each one runs a report based
on a query, and each one will have no data in some instances.

Thanks
Frank in Spokane
 
You error code nicely traps the error..and then gives the user the error
that the report was canceled.

I am quite a lazy programmer, and thus I just use on-error resume next.

However, I *really* don't want to tell you to remove your error handing
code. So, in your error hander..just ignore ONLY the error when the report
is canceled.

Hence, just change your error code to:
Err_Command0_Click:

if err.number = 2501 then
' user canclendd the rerpot...just continue
resume next
end if
 
" Your error code nicely traps the error..and then gives the user the error
that the report was canceled. "

Actually that's standard Microsoft code - not mine.

Anyway your code works great - less filling - and I'm analyzing your
multi-select routines to glean further info.

Thanks Albert!
Frank in Spokane
 
Back
Top