Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / October 2005

Tip: Looking for answers? Try searching our database.

Messages in Access - Suppress or Replace - Access 2k, DAO

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Leonard Priestley - 29 Oct 2005 04:52 GMT
I have been designing reports and have made provision for queries that
return no data.  If this occurs, I provide a user-friendly message advising
the user.  When I try this out, I also get a message from Access saying "The
OpenForm Action was cancelled".  I don't want this message to appear, or
would like to modify it, because I don't think the user will have any idea
what the 'OpenForm Action' is.  How can I suppress the unwanted message or
replace it with one I prefer?

Leonard Priestley
jayan@getinnet.com - 29 Oct 2005 11:52 GMT
hai,

If u want the property details that means buying & selling or guest
house and what ever in property just login the side www.getinnet.com
you will get all the details in this side it will be useful to you. go
ahead.

Not only real estate
Web Design
Web Hosting
Real Estate
Automobile
Allan Murphy - 29 Oct 2005 11:54 GMT
Leonard put the following code in your report NODATA event

Private Sub Report_NoData(Cancel As Integer)
   Beep
   MsgBox "No records match the criteria you entered.", vbExclamation, "No
Records Found"
   Cancel = True
End Sub

A report is called from a form and is displayed as Print preview, Printed,
or sent as an email depending on the user's choice. If there is not data a
msgbox is displayed with the above message. The user clicks OK and then can
make another choice.
Signature

Allan Murphy
Email: allanmurphy@unwired.com.au

> I have been designing reports and have made provision for queries that
> return no data.  If this occurs, I provide a user-friendly message advising
[quoted text clipped - 5 lines]
>
> Leonard Priestley
Leonard Priestley - 29 Oct 2005 23:07 GMT
Allan Murphy,

Thank you for your reply.  Essentially, my code already looks the same as
your suggestion.  That is, I am using the NODATA event, providing a message
and setting Cancel = True.  My problem is that after displaying my message,
and cancelling the event, Access displays a further message - "OpenForm
Action was cancelled", which I don't want.  I know that in the case of an
input mask error it is possible to use acDataErrContinue to tell the program
to keep going and not show its message.  The code looks like this:

Private Sub Form_Error (DataErr As Integer, Response As Integer)
     Const INPUTMASK_VIOLATION = 2279
     If DataErr = INPUTMASK_VIOLATION Then
        MsgBox "There was an input mask violation!"
        Response = acDataErrContinue
     End If
  End Sub

What I am trying to find out is how to do the same  with this darned
"OpenForm Action was Cancelled " message.  I am assuming that cancelling the
report doesn't qualify as an Error event.

Regards
Leonard Priestley

> Leonard put the following code in your report NODATA event
>
[quoted text clipped - 23 lines]
> >
> > Leonard Priestley
Allan Murphy - 29 Oct 2005 23:49 GMT
Leonard

Remove the Cancel=true from your NODATA event in your report. I had the same
problem.

Signature

Allan

> Allan Murphy,
>
[quoted text clipped - 52 lines]
> > >
> > > Leonard Priestley
Leonard Priestley - 30 Oct 2005 05:50 GMT
Alan,

Thank you for your suggestion.  Unfortunately it doesn't exactly solve the
problem for me.  When I remove the cancel = True  it does stop the offending
message, but the message I want delivered does not disappear until the OK
button has been clicked twice (message is coming up a second time, maybe?).
In addition, the blank report appears afterward.  No report appears if I
leave the Cancel = True in the code.

Leonard Priestley

> Leonard
>
[quoted text clipped - 69 lines]
> > > >
> > > > Leonard Priestley
david@epsomdotcomdotau - 30 Oct 2005 00:18 GMT
How are you calling the report?  If you are just letting
the user double click on the report list, you don't
have much choice.

(david)

> I have been designing reports and have made provision for queries that
> return no data.  If this occurs, I provide a user-friendly message advising
[quoted text clipped - 5 lines]
>
> Leonard Priestley
tina - 30 Oct 2005 02:24 GMT
the error message occurs because you cancel the OpenReport action in the
NoData event procedure, but it occurs *in* the procedure that runs the
OpenReport action. standard procedure is to either 1) check for records
*before* running the action, or 2) trap the "action cancelled" error and
handle it.

to do number 1:  you can use a DCount function in your code before the
OpenReport action to check for records returned by the query underlying the
report, as

   If DCount(1, "MyQueryName") > 0 Then
       DoCmd.OpenReport "MyReportName"
   Else
       MsgBox "No data available."
   End If

to do number 2:  add error handling code to the procedure that runs the
OpenReport action, as

   On Error GoTo OpenReport_Err

   DoCmd.OpenReport "MyReport"

OpenReport_End:
   Exit Sub

OpenReport_Err:
   If Err.Number = 2501 Then
       Resume OpenReport_End
   Else
       MsgBox Err.Number & "  " & Err.Description
   End If

hth

> I have been designing reports and have made provision for queries that
> return no data.  If this occurs, I provide a user-friendly message advising
[quoted text clipped - 5 lines]
>
> Leonard Priestley
Leonard Priestley - 30 Oct 2005 06:27 GMT
Yes, thank you Tina,
 I have used your first suggestion and have the result I wanted.
 Have a Nice Day
    Leonard

> the error message occurs because you cancel the OpenReport action in the
> NoData event procedure, but it occurs *in* the procedure that runs the
[quoted text clipped - 42 lines]
> >
> > Leonard Priestley
tina - 30 Oct 2005 06:12 GMT
you're welcome  :)

> Yes, thank you Tina,
>   I have used your first suggestion and have the result I wanted.
[quoted text clipped - 50 lines]
> > >
> > > Leonard Priestley
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.