Duke said:
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