Solved

Lost Focus, Dirty

Posted on 2013-12-12
2
379 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 38

Accepted Solution

by:
PatHartman earned 300 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

635 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