Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, I have a button on one form to

Status
Not open for further replies.

Aydan

Technical User
Dec 14, 2002
51
BE
Hi,
I have a button on one form to open an other form in Add new record mode. First I test if the form is already open with the Isloaded function. The question is, if the form is loaded then when it's dirty property=true (meaning that the form is modified) it should be saved and I want it to go to a new record making this form active (focused).
Any ideas?
 
You can simply set the form's DataEntry property to True. It will automatically move to a new record, saving the previous record if it was modified. This happens even if the form was already in DataEntry mode.

If the current record was modified, but doesn't pass validations (either control or table validation rules, Required checks, or if you cancel a BeforeUpdate event), the form will not enter DataEntry mode, and an error message will be displayed. The user will have to fix the current record before clicking the button on the first form again. Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Hi Rick,
By setting this forms data entry property to true I can't open a related record anymore. Some times I open this form with a linkcriteria. So this is not a resolution.
It's true what you're saying about if the current record was modified, but doesn't pass validations that this will return an error message. Even if this form is saved on afterupdate of almost any important field, the chanse exist that the user did not leave the field so the afterupdate wouldn't be called.
Would it be an idea to open an other instance of this form which always opens in dataentry mode?
Greetings,
Aydan
 
I was really talking about setting the form's DataEntry property to True dynamically at the time you want it to be used to add a new record. You can do that with:
Forms![<form name>].DataEntry = True

You can switch it back to normal by setting the property to False again. Or you can simply close it; the next time you open it, it will return to its properties as defined.

If you know how to use private instances, you could certainly do that, too, setting DataEntry = True before you make it visible. You'll need to take care not to release the private instance before the user is done with it, however.

I didn't follow what you were saying about AfterUpdate events. What I was saying was that, if the form was already opened and dirty when you try to set the DataEntry property to True, it will be sent through the normal record save cycle just as if the user had clicked Save. This includes all the validation rules, Required rules, and BeforeUpdate and AfterUpdate events. If the dirty record doesn't pass the validations, a message will be displayed and the DataEntry property won't be changed. So there's no risk of losing an update, or saving invalid data, when you try to move the form to an empty record. Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Thanks Rick,
Now I understand better. This will suit my problem.
Gonna try it right away!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top