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 / Queries / November 2005

Tip: Looking for answers? Try searching our database.

Query Result pop-up

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
vtkarma - 09 Nov 2005 20:13 GMT
I have a query that searches for previous entries in a employee table and
prints a report if it finds an existing record, i.e. there is an employee by
the name "Smith".  How can I get the query to return a message box that says
"No record found" if there are no records, that match the query parameter?  
Currently I get a blank report.
Rob Parker - 09 Nov 2005 22:01 GMT
The usual way of handling this is not to get the query to return a message
box (presumably by code - you can't do it directly), but to use the NoData
event of the report itself.  An example from one of my applications is:

Private Sub Report_NoData(Cancel As Integer)
 MsgBox "There were no credit card orders in this month", vbInformation +
vbOKOnly, msgTitle
 Cancel = True
End Sub

If you are opening the report via code, you will get a system message that
the previous action was cancelled.  You can supress this by trapping the
error condition as follows:

 ...
 On Error Resume Next
 DoCmd.OpenReport "rptCCOrders", acPreview
 ...

(If you've got other error trapping in place, restore it after opeining the
report.)

HTH,

Rob

> I have a query that searches for previous entries in a employee table and
> prints a report if it finds an existing record, i.e. there is an employee by
> the name "Smith".  How can I get the query to return a message box that says
> "No record found" if there are no records, that match the query parameter?
> Currently I get a blank report.
Ofer - 10 Nov 2005 00:37 GMT
You can't set the query to do that, but you can set the report to do that, by
adding this code to the OnNoData Property in the report

Msgbox "There is no data"
Cancel = true

Signature

The next line is only relevant to Microsoft''s web-based interface users.
If I answered your question, please mark it as an answer. It''s useful to
know that my answer was helpful
HTH, good luck

> I have a query that searches for previous entries in a employee table and
> prints a report if it finds an existing record, i.e. there is an employee by
> the name "Smith".  How can I get the query to return a message box that says
> "No record found" if there are no records, that match the query parameter?  
> Currently I get a blank report.
 
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.