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 / Reports / Printing / March 2008

Tip: Looking for answers? Try searching our database.

In Access check for valid record ID before printing report?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Duke - 24 Mar 2008 20:37 GMT
How do I stop a Access report form showing no data when an incorrect record
ID # is entered into a parameter textbox on an input popup form?
Evi - 24 Mar 2008 21:09 GMT
Put a MsgBox in the On No Date Event of the Report

Private Sub Report_NoData(Cancel As Integer)
Dim Msg As String
Msg = "You haven't entered any figures for this period yet"
'put your own message here
MsgBox Msg
DoCmd.CancelEvent
End Sub

> How do I stop a Access report form showing no data when an incorrect record
> ID # is entered into a parameter textbox on an input popup form?
Larry Linson - 25 Mar 2008 02:12 GMT
> How do I stop a Access report form showing no data when an incorrect
record
> ID # is entered into a parameter textbox on an input popup form?

A better approach is to create a ComboBox with its RowSource being a Query
that extracts the record ID #s from the RecordSource and Limit to List, so
the user can NOT "enter an incorrect record ID".  It's little things like
this which make an application "user-friendly" and keep your clients/users
happy.

What do you mean "keep it from showing 'no data'"?  You can cancel the
Report in the OnNoData event in recent versions of Access and manipulate the
properties to minimize the system messages that are displayed. Or, you can
write VBA code behind the Form to check that the value in the TextBox is a
valid Record ID and never call the report if it is not.

Caution: "Air Code", untested

Public Sub()
   Dim db As DAO.Database
   Dim rs As DAO.Recordset
   Set db = CurrentDB()
   Set rs = db.OpenRecordset ("nameofyourRecordSourcehere")
   If Not (rs.BOF and rs.EOF) Then
       rs.MoveFirst
       rs.FindFirst "[ID #] = " & Me.txtID#
       If Not rs.NoMatch Then
           DoCmd.OpenReport "nameofyourReporthere",  . . ., "[ID #] = " &
Me.txtID#
       Else
           MsgBox "No such Record, please try again"
       End If
   Else
       MsgBox "There are no records in the Record Source"
   End If
   rs.Close
   Set rs = Nothing
   Set db = Nothing
   Exit Sub
End

The above uses [ID #] for your Field name (replace with your own field name)
and assumes the Field ID # is numeric. You'll need extra quotes if it is
Text.

Larry Linson
Microsoft Office Access MVP
 
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.