Check for empty records on filter

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all

I have a routine to add records via code for a persons weekly itinerary. I
want to put a check in first to make sure no entries for the weeks date range
chosen exist already. I can achieve this in code but I also have a filter on
the form which already checks this kind of. If the filter is applied and no
records are selected then it will be ok for the user to use my routine to
book the week.

Is there a way to check if a returned recordset on a form is empty after a
filter has been applied? See filter below:

Dim Fltr

Fltr = "[ReviewDate] >= " & _
Format$([StartDate], "\#mm\/dd\/yyyy\#") & _
" And [ReviewDate] <= " & _
Format$([EndDate], "\#mm\/dd\/yyyy\#")

Fltr = Fltr & " AND " & "[Specialist] = " & Me.SpecFilter
Me.Filter = Fltr

Me.FilterOn = True
 
Get the RecordCount of the form. This number is adjusted to the displayed
records, so when a filter is applied, the number goes down.

Me.Recordset.RecordCount
 
Thanks Wayne, this worked perfectly.

Wayne Morgan said:
Get the RecordCount of the form. This number is adjusted to the displayed
records, so when a filter is applied, the number goes down.

Me.Recordset.RecordCount

--
Wayne Morgan
MS Access MVP


hughess7 said:
Hi all

I have a routine to add records via code for a persons weekly itinerary. I
want to put a check in first to make sure no entries for the weeks date
range
chosen exist already. I can achieve this in code but I also have a filter
on
the form which already checks this kind of. If the filter is applied and
no
records are selected then it will be ok for the user to use my routine to
book the week.

Is there a way to check if a returned recordset on a form is empty after a
filter has been applied? See filter below:

Dim Fltr

Fltr = "[ReviewDate] >= " & _
Format$([StartDate], "\#mm\/dd\/yyyy\#") & _
" And [ReviewDate] <= " & _
Format$([EndDate], "\#mm\/dd\/yyyy\#")

Fltr = Fltr & " AND " & "[Specialist] = " & Me.SpecFilter
Me.Filter = Fltr

Me.FilterOn = True
 
Back
Top