blank form when filter applied

  • Thread starter Thread starter max
  • Start date Start date
M

max

Hi,
I have a form with employee details like name, age, ID, and
so on. On the form, there's a textbox where the user enters
a filter criteria (eg "30") so as to display only those
aged 30. The user then presses a button to set the filter.

When there are no records that meet the filter criteria,
the details section of the form goes blank.
I would like it to happen that when the user presses the
button and there are no records that meet the filter
criteria, instead of the form blanking out, a message
appeares saying that "NO records meet the criteria" and the
filter is removed.

How do I go about this?? Thanks in advance
 
The Detail section of a bound form goes completely blank when it is filtered
so that it contains no record AND no new records can be added.

In the code that applies the filter, you could do something like this:

If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "No records"
Me.FilterOn = False
End If
 
Max,

Does the button fire a macro or some code?" In either case, add a check
like:
DFirst("[WhicheverField]","Table","[AgeField]=" &
[Forms]![FormName].[FilterTextBox]) =""
(replacing with the real names) so if the condition above is satisfied, a
message box is displayed and the rest of the macro or code is not executed.

HTH,
Nikos
 
Back
Top