Maximum entries in a table

hmigneronhmigneron Member Posts: 5
Hello all,

I have a table that I use in a subform. I want this table to store a maximum of say, 5 records. If the user tries to enter more than the 5 records, he should get a message saying that it's impossible to add more.

By adding some code in the OnNewRecord trigger of the subform, I get a message at the appropriate time:
IF COUNT >= 5 THEN BEGIN
  ERROR(Errormsg);
END;

Now, my problem is that when I use ERROR, the whole subform closes. When I use MESSAGE instead of error, the message is displayed fine, but the new record line is still selected afterwards, and the user can just continue entering data.

My question is: how can I display a message, and then select the fifth record whenever the user tries to insert more than 5 records.

Thanks

Comments

  • fverkelfverkel Member Posts: 66
    I have had the same wish.

    In the trigger OnNewRecord I have out a message.
    In the OnInsertRecord I have put the same message, followed by EXIT(FALSE).

    So if the user tries to add a record, he gets the message.
    If the user still proceeds, then he gets the message and the record will not be inserted. The form will not be closed, and the previous line will be selected.

    Maybe this helps you.
    Keep It Simple and Stupid (KISS), but never oversimplify.
  • hmigneronhmigneron Member Posts: 5
    Does the trick for me!

    Thanks for your help
Sign In or Register to comment.