Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Lost Focus, Dirty

Posted on 2013-12-12
2
Medium Priority
?
385 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 39

Accepted Solution

by:
PatHartman earned 1200 total points
ID: 39714241
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
ID: 39745474
thank you
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

715 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