Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data entered into form does not immediatly update underlying table

Status
Not open for further replies.

Bra81ndy

Technical User
Oct 25, 2007
5
US
A main form is used to enter data for glue formulations. I create a new record and enter the name for the formulation in the specified control. This data will not show up in the underlying table unless I switch records or click on a sub-form. I feel that I need some kind of code in an event such as "on lost focus" or "after update". But I do not what code to use for this. I do not have much code experience.

Thanks.
 
It seems to me that you want a save button. You can create one with the wizard. It is not strictly necessary as Access will save by default. In other words, if you closed the form, you should find the data in the underlying table, even though it was not saved by you.
 
use me.refresh. You can use it in the field's "afterupdate" event or anywhere that works for you.
 
I opened the form in design view. I opened the properties for the control and wrote me.refresh in the box for After Update. I switched back to form view and inputted a name for a formulation. When I tabbed to the next control it gave the following error, Microsoft Office Access can't find the macro "me". How do I make a me macro? What exactly happens in the background when someone changes records?
 
You need to code it, in the event procedure property select code builder from the drop down and put the refresh line into the code window that pops up.
 
For someone unused to coding, it may be easier to use the wizards to add a Save button. You can also choose a variety of actions from the toolbars.

Access automatically saves the current record when you move to another record or when you close the form. Reasons for saving a record 'manually' might include:

* You wish to print
* You wish the record to be available to a control or form.

It is probably not necessary to be concerned that the current record is not available in the underlying table. I would be worried if some other record was not available :)
 
Thank you for your help. I believe I have solved the problem. I added a macro that uses Runcommand to Saverecord. I put this macro on the controls in the After Update field for which I want to immediately update. So far this is giving me the results that I wanted to see. I need certain controls to update the values in the underlying tables, because I use these values in queries that are called by macros.
 
If you make sure that the wizard button is pressed on the toolbox toolbar when you add a command button to a form in design view, it will offer you a variety of options, one of which is Save Record, available under Record Operations from the wizard window. This will generate code for your button, a better way to go than a macro.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top