How to avoid update?

  • Thread starter Thread starter Igor
  • Start date Start date
I

Igor

Hi,
I have tab control on one of which pages is subform.
When I change data on one of pages and navigate to another, update in
database is happened.
Is there any way to avoid that?
Thanks
 
Jet uses opportunistic record saving (automatic on form closing, when time
permits while changing focus, etc.), so no explicit "Save" command is needed
for most applications. Why would you want to disable this?
-Ed
 
Using an embedded subform when you leave the subform it loses focus and
the (sub)record gets saved. You might consider using temporary tables
to hold the data (the save still happens but to the temporary table).
You could then take whatever additional actions you wanted to take and
depending on whether or not you wanted to commit the changes you could
explicitly 'save' the record to the permanent tables using code or an
update/append query.
 
because I have a button for save and button for exit, so database is not
supposed to be updated just
because walking between pages. I can change data on one page, move to
another, decide that I don't want
this change and exit form.
It is especially ridiculous because I have confirmation message on Before
Update event
that asks if you want to save record, so this message pops up every time I
navigate to another page.
 
Sorry, no. The Form / Subform combination is (mainly) designed to handle
Records in a One-to-Many realtionship and to enforce the R.I., the Record on
the MainForm is automatically saved when the Focus is moved from the
MainForm to the Subform. The Record on the Subform is also automatically
saved when the Focus moves from the Subform to the MainForm.

There are some work-arounds, e.g. using temp Tables or unbound Form/Subform
but they are equally messy and a fair bit of VBA code is required.
 
To flesh out this answer a little more...

Often, when there is a need to save data in several tables all at once (such
as a master and details), it's best to have some kind of batch posting
mechanism, so the data is entered into a staging table or with a pending
status, then, when a Post action is requested, copy the data into the
permanent table, or remove the pending status flag on the master record for
the entry.

There are side benefits to this approach, including the fact that a user can
leave an entry 1/2 done, close the program, come back later, finish it, and
post it. This scheme can also overlap with other useful business metaphors,
for instance, a pending order can double as an estimate.
 
This works for me ... my save button is called cmdSave ...

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Screen.ActiveControl.Name <> "cmdSave" Then
Cancel = True
else
... whatever you want to do before updating the record

end if

HTH,
Debbie


| Hi,
| I have tab control on one of which pages is subform.
| When I change data on one of pages and navigate to another, update in
| database is happened.
| Is there any way to avoid that?
| Thanks
|
|
 
Back
Top