Update underlying table (2 Viewers)

Pat Hartman

Super Moderator
Staff member
Local time
Today, 17:03
Joined
Feb 19, 2002
Messages
43,300
The way I've designed this, the change should occur (into the table) immediately... without any extra click. So I was thinking of the after update event, but that means that for every control that might be changed. Or am I on the wrong track ?
I don't understand your objective. In a properly designed table, some fields would be optional and some would be required. Forms are intended to work on the entire record, not just individual fields. So when the user is finished updating the current record, he moves on. That could mean that he closes the form or scrolls to a new record or perhaps you made a button to push to indicate he wants to save. Access is very responsible about saving records and most people are troubled by the fact that Access saves too much rather than not enough. In any event, you would NEVER want to save after the entry of each field because that would prevent you from employing rules that say that certain fields MUST be present in order for a record to be valid.

You also mentioned that you were entering data in a temp table and then moving to the permanent table. This extremely tricky in a multi-user environment. It's not bad for adding data but updating and deleting is fraught with danger. You enter the data in the temp table and validate it along the way but databases are not static so what if between the original entry and the move to the permanent table something changes that would make the validation rule fail? Now you've added bad data to your production table. The only case were I would use temp tables is for an app where I needed to do "batch" entry. An entire set of records must be entered and validated and balanced. Once they'r complete, then they can be made permanent. Once they are permanent, they can not be changed again. The entire batch needs to be flagged as deleted and you start again.
 

nonakag

Member
Local time
Today, 11:03
Joined
Apr 30, 2013
Messages
54
Hello, I tried to use my save button to trigger the DoCmd.Save method, which in-turn triggers a refresh to a control on another form. However, I can stay on that record and hit save all day and watch the control refresh and never change. It takes a move off the record and then another refresh to update the control that is connected direct to the table. Why is this? Should I be using Me. Dirty = Yes? to get this to do what I want (basically an instant update to the control on the other form, after a refresh)? Thank you.
 
Last edited:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 17:03
Joined
Feb 19, 2002
Messages
43,300
DoCmd.Save does NOT save the current record.

Use.
Code:
If Me.Dirty Then
    DoCmd.RunCommand acCmdSaveRecord
End IF

OR

Code:
If Me.Dirty Then
    Me.Dirty = False            '' forces record to save
End If

If you have multiple forms open, it is best to make the second form a dialog so that control stays with it until you close it. Then control returns to the calling form. This allows you to refresh the first form when the second form closes.
 

nonakag

Member
Local time
Today, 11:03
Joined
Apr 30, 2013
Messages
54
DoCmd.Save does NOT save the current record.

Use.
Code:
If Me.Dirty Then
    DoCmd.RunCommand acCmdSaveRecord
End IF

OR

Code:
If Me.Dirty Then
    Me.Dirty = False            '' forces record to save
End If

If you have multiple forms open, it is best to make the second form a dialog so that control stays with it until you close it. Then control returns to the calling form. This allows you to refresh the first form when the second form closes.

Pat, thanks for the information. the Me.Dirty=False Property works great. the form I'm updating after the save record, is a Switchboard that has a dual function as a Dashboard, for a vehicle fleet status, and also the Main Menu to the other Forms. The status tracks Vehicle Mileages, Dead-lined or In-Commission, and Inspections Overdue or Soon to be do. So, Lots of updates going to the Dashboard as things get saved from other Forms. Therefore the update should happen as soon as the save button is hit, not when the Form closes. Thank you.
 

Users who are viewing this thread

Top Bottom