How does a save button handle the record?

ijswalker

Registered User.
Local time
Today, 07:05
Joined
Jun 16, 2008
Messages
67
I have a conceptual question that may help me understand what a save button actual does if written correctly.

My thought is that when a record is retrieved from the database and displayed on a form , the fields are not bound to the database. When the save button is clicked it takes the information filled in on the form and updates the underlying record in the database. This is opposed to have the record bound to the field where it is updated automatically once the record is changed.

Would I be correct in saying that? I am trying to get a good understanding of what is actually happening in order for me to create a database more efficiently. Pick my thoughts apart if you need to. I am trying to learn as much as possible.

Thanks

Ian
 
Simple Software Solutions

You are half way there. When using bound forms fields are updated as per key stroke. and undone using the undo, escape or ctrl-z options.

The save command button works in the same way if you have bound fields on the form. If you are using an unbound form then the act of clicking the button would not do anything unless you told it what to save. Unbound forms give more flexibility, but the down side they involve additonal vba input.

CodeMaster::cool:
 
Data is not saved keystroke by keystroke. The record is saved automatically under any condition that causes the underlying record pointer to move. Or in the case of a form/subform - moving from the form to the subform automatically saves the form record and moving from the subform to the main form automatically saves the subform record. Of course, navigating forward or backward in the form's RecordSource will save a dirty record as will closing a form.

Access keeps three copies of a record in memory.
1. the original values that were read when the form was populated. - the .OldValue property references this value
2. the values as they have been changed. - the .value property references this value.
3. the values as they are being typed into a control - the .text property will return this value and the control needs the focus to reference the .text property.

A save button should contain code similar to:
If Me.Dirty Then
DoCmd.RunCommand acCmdSaveRecord
End If

if you use the wizard to generate the code, it references some menu option from Access95. Delete this code and replace it with what I suggested.

If you use Unbound forms, you have to write all the code yourself to navigate the recordset, populate each field, update each table field when the user asks to save the record.

Access is a Rapid Application Development environment BECAUSE it uses bound forms and reports. So, unless you have some ultra-special need to use an unbound form, stick with bound forms and learn how to use the events and properties correctly. You will have all the control you need.
 

Users who are viewing this thread

Back
Top Bottom