Forcing form to update

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Using Access97 I have a form for creating/editing a single record i.e. no
navigation buttons necessary. My problem is that when I open another form via
a button on main one, the data on the main form does not get saved because I
haven't moved off the record, and I cannot reference that data with the
second form.

I want a way to force the form to save it's data when it loses the focus, or
when the second form is invoked via a command button.

Does anyone know how to do this?
 
Hi,

You could amend the code on the command button to first save the current
form, which will save all records on it, and then open the other form.

Use something like

docmd.save

followed by your code to open the second form.

hth

Mark

* This information is provided "as is" and confers no rights or expresses
any warranties.
 
Using Access97 I have a form for creating/editing a single record i.e. no
navigation buttons necessary. My problem is that when I open another form via
a button on main one, the data on the main form does not get saved because I
haven't moved off the record, and I cannot reference that data with the
second form.

It should, this from Help .........
The BeforeUpdate and AfterUpdate events are triggered when a control
or record is updated. Within a record, changed data in each control is
updated when the control loses the focus or when the user presses
ENTER or TAB. When the focus leaves the record or if the user clicks
Save Record on the Records menu, the entire record is updated, and the
data is saved in the database.

When you enter new or changed data in a control on a form and then
move to another record or save the record by clicking Save Record on
the Records menu, the BeforeUpdate and AfterUpdate events for the form
occur immediately after the BeforeUpdate and AfterUpdate events for
the control. When you move to a different record, the Exit and
LostFocus events for the control occur, followed by the Current event
for the record you moved to, and the Enter and GotFocus events for the
first control in this record. To run the BeforeUpdate and AfterUpdate
macros or event procedures without running the Exit and LostFocus
macros or event procedures, save the record by using the Save Record
command on the Records menu.

BeforeUpdate and AfterUpdate macros and event procedures run only if
you change the data in a control. These events don't occur when a
value changes in a calculated control. BeforeUpdate and AfterUpdate
macros and event procedures for a form run only if you change the data
in one or more controls in the record.
For forms, you can use the BeforeUpdate event to cancel updating of a
record before moving to another record.
I want a way to force the form to save it's data when it loses the focus, or
when the second form is invoked via a command button.

Does anyone know how to do this?

So from the above you can see that using DoCmd.acSaveRecord when the
last control loses focus will force it to do that, but it should have
already been done ... unless ... the record on the second form is the
same record as what is current on the first form.

But you wouldn't be doing that .... would you?

Cheers,
Brett
 
Back
Top