Limit the records on a subform

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

Guest

Hello:

Here's what I've got. A database with a subform in it. The subform is
ordered ascending by date. Each main form record has a related subform set of
records showing each date from now until the end of the year.

I want to limit the records shown in my subform to only the current month. I
do not want users to be able to enter data in for a date past that. I'm not
interested in having Access just show current month. I would like to control
it, or update the month shown to prevent users from prematurely entering info
into the database before we are ready for the following months data.

Basically I just want to limit the records shown in the subform to current
month, even though I've got a full year of info in the table.
 
I want to limit the records shown in my subform to only the current month. I
do not want users to be able to enter data in for a date past that. I'm not
interested in having Access just show current month. I would like to control
it, or update the month shown to prevent users from prematurely entering info
into the database before we are ready for the following months data.

Basically I just want to limit the records shown in the subform to current
month, even though I've got a full year of info in the table.

You'll need to do two things: first limit the display of records to
the current month, by basing the Subform on a query including a
criterion like
= DateSerial(Year(Date()), Month(Date()), 1) AND < DateSerial(Year(Date()), Month(Date()) + 1, 1)

Secondly, to prevent users from entering a record with a date outside
the current month, use the BeforeUpdate event of the date field
textbox to check that the entered date is within the range shown
above. Warn the user and Cancel the update if it's not.

John W. Vinson[MVP]
 
Back
Top