Limit the records on a subform

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.
 
J

John Vinson

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]
 

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

Top