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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving a record when allow additions = False

Status
Not open for further replies.

zevw

MIS
Jul 3, 2001
697
US
Hi!

There are subforms where I only have one record, and based on the entry of the user I would like to set the status of the main form. That can only happen if the record is saved while the user has focus of the current record. How can I make sure that the user saves the record before moving on?

Before Update cannot happen, only if the user moves on to the next record, which in our case is not possible because AllowAdditions = False. So then only if the user will click in the main form, what will force the user to do that?
 
I'm not very good with bound forms as I avoid using them wherever possible but I think the Dirty property of the form may do what you want.

Ed Metcalfe.

Please do not feed the trolls.....
 
You may wish to look at:
KISS way to force users to click a command button to exit a form regardless of menu or toolbar options
faq702-2071
 
Thank you all, for taking the time to answer me.

Ed!

On Dirty is good for starting a change in a record. My problem is once you entered / changed a record and the user will leave how will I stop the user from closing the form before they save the record and remember there is no where to click only in the current record.

Remou!

I think that is a great FAQ and it will for sure come to good use. This option is good, when the user wants to close the form. In my case if the user will click on next record, that is in the parent form, and move on the before update in the subform does not happen. What can we do in that case?
 
How about:

Behind the Form_Dirty event of the subform:

Code:
Forms("ParentFormNameHere").NavigationButtons = False

And behind the command button to save the subform's record:

Code:
Forms("ParentFormNameHere").NavigationButtons = True

It was irritating little problems like this that led to me abandoning bound forms fairly quickly.

Ed Metcalfe.

Please do not feed the trolls.....
 
How are ya zevw . . .

Any qualms about a save button?
Code:
[blue]   docmd.RunCommand acCmdSaveRecord
[purple]or:[/purple]
   If Me.Dirty Then Me.Dirty = False[/blue]
[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thanks!

I have a save button with the above command, but what forces the user to hit that button?
 
Have another look at the FAQ. You can use the idea to prevent any other action, unless the save button is clicked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top