Check for empty records on filter

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
 
W

Wayne Morgan

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top