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 / Modules / DAO / VBA / May 2005

Tip: Looking for answers? Try searching our database.

No data event in report

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
PeterW - 05 May 2005 14:12 GMT
I have a command button on a form that I am using to open a report showing
items to be despatched on a job. I have the following code on the click event
Private Sub btnDespatchList_Click()
   Dim strWhere As String
   
   strWhere = "qryDespatchList.tblShopJob.JobNo =" & "'" & Me.JobNo & "'"
       'open despatch report for current order
       DoCmd.OpenReport "rptDespatch", acViewPreview, , strWhere
       
End Sub
The report worked fine until I added the following to the nodata event on
the report
Private Sub Report_NoData(Cancel As Integer)
   'Give message that no items are ordered for this job yet
   MsgBox "No items are ordered for this" & vbCr _
          & "Job currently", vbInformation
  Cancel = True
   
End Sub
If there is no data present the message box appears and then a debug message
come up saying openreport action was cancelled and then goes to the Private
Sub btnDespatchList_Click() event - anyone tell me how to stop this please -
I have used this before and it worked ok
Allen Browne - 05 May 2005 14:22 GMT
Add error handling to btnDespatchList_Click()
In the error handler, tell it to ignore error 2501

Example:

Private Sub btnDespatchList_Click()
On Error Goto Err_Handler

   DoCmd.OpenReport ...

Exit_Hander
   Exit Sub

Err_Handler
   If Err.Number <> 2501 Then
       MsgBox "Error " & Err.Number & " - " & Err.Description
   End If
   Resume Exit_Handler
End Sub

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

>I have a command button on a form that I am using to open a report showing
> items to be despatched on a job. I have the following code on the click
[quoted text clipped - 23 lines]
> please -
> I have used this before and it worked ok
PeterW - 05 May 2005 15:26 GMT
Many thanks for your reply I have altered the code and this now works fine

> Add error handling to btnDespatchList_Click()
> In the error handler, tell it to ignore error 2501
[quoted text clipped - 43 lines]
> > please -
> > I have used this before and it worked ok
 
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.