Solved Validation Rules on Form Close/Click on Previous record

ahmad_rmh

Member
Local time
Today, 05:58
Joined
Jun 26, 2022
Messages
243
I am applying validation rules on form close/go to previous record on main form and subform. The requirements are as under;

1. If the user just enters the information on the main form and wants to save record or wants to exit then show a message,
"You cannot record a blank transaction".
2. Undo/delete the information if he wants to leave.

3. On the other hand, if the user directly enters the items detail on the sub form and leaves the main form blank and wants to save the record or exit then show a message,
"Warehouse information cannot be left blank"
4. Undo/delete the information if he wants to leave.

Suggestions are required please.
 
Hi
This statement is all wrong:-

"
3. On the other hand, if the user directly enters the items detail on the sub form and leaves the main form blank and wants to save the record or exit then show a message,
"Warehouse information cannot be left blank"
4. Undo/delete the information if he wants to leave."

The purpose of a Main Form / Subform is to ensure that you have details in the Parent before you are allowed to
enter details for a Child record.
 
Hi
This statement is all wrong:-

"
3. On the other hand, if the user directly enters the items detail on the sub form and leaves the main form blank and wants to save the record or exit then show a message,
"Warehouse information cannot be left blank"
4. Undo/delete the information if he wants to leave."

The purpose of a Main Form / Subform is to ensure that you have details in the Parent before you are allowed to
enter details for a Child record.

Who has told you this is all wrong,

It's up to you at which place you want to make limitionations or validations,

For the end user easiness, Many modern software are working like this.

So, I will move on this way.
 
Who has told you this is all wrong,

You want to wind your neck in a bit mate, you're starting to piss people off. Mike is trying to tell you that you can't save a record in the subform without a record in the main form, it just won't work. So try and listen to people and stop being a dick!
 
Last edited:
The same thing I have written that if anyone of the conditions will not met then it will pop up message.

But mike said, this statement is all wrong.

I want codes for the said conditions.
 
I am applying validation rules on form close/go to previous record on main form and subform. The requirements are as under;

1. If the user just enters the information on the main form and wants to save record or wants to exit then show a message,
"You cannot record a blank transaction".
2. Undo/delete the information if he wants to leave.

3. On the other hand, if the user directly enters the items detail on the sub form and leaves the main form blank and wants to save the record or exit then show a message,
"Warehouse information cannot be left blank"
4. Undo/delete the information if he wants to leave.
Suggestions are required please.

A better approach would be to stop the user gaining access to the subform until they have completed the main form.
 
Thanks, it's simple and easy to implement but as you know I am a learner if I want to implement like that way then what is the solution.
 
See here:-


And here:-

I prefer to lock the subform/subreport control, see here:-

Post in thread 'How do I lock a subform?' https://www.access-programmers.co.uk/forums/threads/how-do-i-lock-a-subform.200841/post-1012226
 
Last edited:
The simplest solution to preventing data entry in a subform is to use the subform's BeforeInsert event. This event runs ONLY for new records and it runs immediately after the user types the first character. In this event, you examine the PK of the main form. If it is Null, then you cancel the BeforeInsert event and give the user a message that he cannot enter data at this time.

Tony and I are making videos and this is referenced in our very first one.


You should be able to just click on play without creating an account.

Please let us know what you think. Thanks.
 
Thanks, it's simple and easy to implement but as you know I am a learner if I want to implement like that way then what is the solution.

@ahmad_rmh
At time index 25 minutes in @Pat Hartman's video, there is an explanation of what you need to do, along with the code. Just copy the code presented in the video and hey presto, you should have a working validation routine...
 
Actually I am busy in management tasks in office today so I will let you know tomorrow,

Thanks
 
Very helpful to see the Order of Events. The dialog between you two is also helpful.

Tony, I tried adding a comment to the video at the ScreenCastOmatic site, but was told
"oops an error has occurred- something went wrong - we are working on it". And it did offer a button to Go Back-but it did not go back???
 
Last edited:
Tony, I tried adding a comment to the video at the ScreenCastOmatic site

Thanks Jack, I'll let Screen o'matic know... They are pretty hot on getting things fixed!!!
 
Thanks Jack, I'll let Screen o'matic know...

Hi @jdraw ,
I went to the site to create a support ticket but I note that a comment appears in the list. From the way it reads, my guess is it was your comment... Can you see it it now?
 
The simplest solution to preventing data entry in a subform is to use the subform's BeforeInsert event. This event runs ONLY for new records and it runs immediately after the user types the first character. In this event, you examine the PK of the main form. If it is Null, then you cancel the BeforeInsert event and give the user a message that he cannot enter data at this time.

Tony and I are making videos and this is referenced in our very first one.


You should be able to just click on play without creating an account.

Please let us know what you think. Thanks.
I think that's the clearest explanation of the situation I've ever seen or heard. (y)
 
Hi @jdraw ,
I went to the site to create a support ticket but I note that a comment appears in the list. From the way it reads, my guess is it was your comment... Can you see it it now?
Tony,
Yes that's my comment. Unsure what may have happened.

Just saw George's note, and I agree --very clear and focused info/explanation.
I like the idea of showing the events as they occur. I use it quite often - I think a forum or newsgroup (back in the day) encouraged people to show each event in order and review same. Event style programming is different than we were used to with Cobol. PL/1, Fortran....(y)
 
Very helpful to see the Order of Events. The dialog between you two is also helpful.

Hi Jack,
Further to this AWF comment, but really, more in answer to the comment you made on the screencast o'matic hosting site.

Yes there were some surprises in how the events are ordered.

Pat is working on the sample database (as per the one shown in the video), adding some features to make it easy to implement. I think her intention is to release a free copy to go along with the video. (it's not really my video, it's mostly Pat!) I'm trying to persuade Pat to release a free copy along with a "paid for" copy. In other words, two levels following the freemium model, basic dB provided free of charge and a dB with more advanced features, which must be paid for.

I haven't told her this yet!
 
Last edited:
Tony,
I have a feeling she'll pick up on that little secret if she's following the forum.;)
Has she ever created Youtube content? Good voice, knowledgeable and experienced.

It would be nice if the Northwind 2 had some similar basic, but critical, info.
 

Users who are viewing this thread

Back
Top Bottom