Restricted number of records in form and subform

  • Thread starter Thread starter simona67_99 via AccessMonster.com
  • Start date Start date
S

simona67_99 via AccessMonster.com

Hi everybody,

I have a form which updates a table that contains among other fields: "Month"
and "Employee Name". For each month and each employee there is ONLY one
record allowed. How can I check if the user of my DB is inserting a second
record for the same month and employee and prevent him from saving?

Somebody suggested I make a condition in the BeforeUpdating but I am a
beginner with Access and can't really write CODE. Could somebody help me with
this? (show me the procedure in SQL).

In the same form I also have a subform in which I am only allowed to insert 5
records (for each record from the master form). Where do I put the condition
there? The subform is in Datasheet view and when the user tries to start the
6th record I want Access to display a message and block him.

Help is really appreciated!!! I am presenting the whole thing to my boss on
Monday!!!

Thank you,

Simona
 
Sounds to me like the Month and Employee Name should be the primary key on
the table.
 
You could use the DCount function in the before update or use could try to
use DISTINCT in a SQL statement

I would use the DCount function as I am not sure you can use DISTINCT with
two fields.
 

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

Back
Top