Save record and refresh(all controls)

J

John Keith

I have a sinple form that uses a local table that can be maintained
seperately from a mainframe daily-refreshed table on a back-end database.

I have added a Red-Box that is set to visible when the local field's data is
different from the back-end data. Clicking the box will copy the data from
the back-end to the local table's field. I am using the current as well as
the data-fields After_update event(s) to set the visibility of the red-box.
When I use the enter or tab key to make changes to a field making it
different or making it the same, the cursor advances to the next field and
the little-pencil (record is not saved) icon is showing only while still in
the field. The red-box visibiliy/invisibility is set properly as the data
changes back and forth.

I have the On-click routine for the field's red-box set to popup a msgbox
with a yes/no Do you want to change the data to "back-end-value". Selecting
yes sets the field to the new data. But it wont act the same as just
changing the value manually.

I have added code in the afterupdate event to:
Call red-box visibility routine (here and after the saves made no
difference)
DoCmd.RunCommand acCmdSaveRecord
Me.Dirty = False
Me.Refresh
Me.Requery
Call red-box visiblity....

Tried all combinations of these but the only way I get the red-box's
visibility to follow the field values correctly is to advance to the next
record and then come back to the original record. The pencil-icon stays on
the record after moving to other fields still (which does not happen when
leaving the edited field with enter or tab)

How do I make the after update routine do the complete save and refresh all
controls (so the red-box gets it's visiblity set properly)
 
J

Jeanette Cunningham

Hi John,
in the code that copies the new data to the local field, have it also set
the red box to invisible.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
J

John Keith

That worked, Thanks!

I still needed the call to set visibility in the AfterChange routine to
catch the manual edit changes, I guess the AfterChange doesn't fire when code
updates the control is why.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top