Solved

Lost Focus, Dirty

Posted on 2013-12-12
2
328 Views
Last Modified: 2013-12-29
Experts,
Is the below advisable in a multi user environment?

Private Sub Form_LostFocus()

    DoCmd.RunCommand acCmdSaveRecord
    'sometimes get error of same person trying to edit record and not sure if save record is cause of it.
   
End Sub
0
Comment
Question by:pdvsa
2 Comments
 
LVL 34

Accepted Solution

by:
PatHartman earned 300 total points
Comment Utility
The form's GotFocus and LostFocus events run ONLY if the form has no control that gets the focus so your code is never executing.

Access is very conscientious when it comes to saving data.  You don't need to do anything in a bound form to make a save happens.  Access takes care of it whenever the record pointer changes and there are numerous situations where this would happen including closing the form.  Most people struggle with stopping Access from saving their data - mostly because they don't understand that the Form's BeforeUpdate is the key and tend to use the shotgun approach to coding.

In general, I would not recommend putting any validation code or code that forces a save in the LostFocus event of a control.  Just because the user tabbed into the control doesn't mean he changed anything so you don't need to take any action regarding validating or saving since nothing was changed.  The BeforeUpdate event of the control/form are where most validation would be placed.

The Dirty event is also inappropriate for validation/force saving because it fires as soon as a single character is typed so that is way too soon in most cases to do any validation and you certainly don't want to save a record that contains only a single character.
0
 

Author Closing Comment

by:pdvsa
Comment Utility
thank you
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now