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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving Current Records 1

Status
Not open for further replies.

bigmerf

MIS
Oct 4, 2002
247
US
I'm trying to save a record on a form after any field has been updated/changed on that specific form.

I've tried using the "DoCmd.RunCommand acCmdSaveRecord" logic within the OnCurrent, AfterUpdate, BeforeUpdate and OnDirty properties yet I am still not able to save the current record.

Basically, the form that is in question is an "edit" form where users can change many different fields at any point. I want to be able to save that record to the table (which is bound to the form by the way), without having to exit the form at all.

Is there any way to do this?

Any help would be great!
 
DoCmd.RunCommand acCmdSaveRecord will save the current record. It is more problem stopping Access saving than not. What is not happening that you wish to happen?
 
Yeah, I've used the "DoCmd.RunCommand acCmdSaveRecord" many times before, and it's a common practice of mine to use this.

I'll try to explain in more detail what is happening:

I have a OrderDetail Form that is currently open. Based on this OrderDetail Form I open an InvoiceForm. After printing my invoices, I realize that the "Order Date" is incorrect so I click on my OrderDetail Form and change the order date. When going back to the invoice form and printing the invoice, the "Order Date" is still displaying the incorrect date.

What I really want to have happen is that any time ANY field within the current record on my OrderDetail form changes, I would like it SAVE so that when I print my invoice the most recent information is correct. I don't want to have to close the form and reopen it so the record is saved.

Does that help a little more I hope?

Thanks!
 
So you save the order form, but do you update the recordset (requery) of the invoice form?
 
Probably all you need to do then is requery the invoice form every time it gets focus. In the On Got Focus event of the Invoice form try:

Me.Requery
 
No, that's the problem -- I am unable to figure out how to save the Order Form Record. The only way the record will save is if I close the form and re-open it, which I don't want to do.

To follow up with the other question(s), using the me.requery on the Invoice Form wouldn't do any good seeing how the "Order Date" that I need to update comes from the OrderDetail Form.

 
How are ya WLTC . . .

Curious . . . [blue]whats preventing you from updating the Date from your Invoice form?[/blue] . . .

Calvin.gif
See Ya! . . . . . .
 
Is your date field on the OrderDetail form bound? If so, the me.requery should work.
 
Well, when updating the "Order Date" field on the OrderDetail Form, both the OrderDetail Form and Invoice Forms are open. I do not want to have to close either form. The "Order Date" field is bound to the OrderDetail form/table.

The Order Date that prints on the invoice comes from the Order Table/Form, however after I change the date, or any field for that matter, I can't save the record unless I press a button or something. I want to be able to change any field on the record, and have the entire record save automatically so when I click back to the Invoice Form to preview my invoice, it will show all the real-time Order information.

So to answer AceMan, how would I update the "Order Date" on the OrderDetail Table from the Invoice Form?

And Krets, yes the "Order Date" is bound to the OrderDetail Form. When would I run the me.requery logic? I've tried OnDirty, AfterUpdate, BeforeUpdate, etc...

Any ideas? Thanks for all the help everyone!
 
When would I run the me.requery logic? What OnEvent would work?
 
On 19 Apr 07 15:55 krets suggested the Got Focus event, did you try that?
 
Well, if the Invoice Form is open, and has the focus, then I click back to the OrderDetail form, which was also open -- then I change the order date on the OrderDetail form, then click back to the Invoice Form, how would a me.requery work on the Got Focus event? Got Focus of what, the Invoice Form? I couldn't do the requery on Got Focus before updating the date......
 
In the Dirty event procedure of the OrderDetail form:
DoCmd.RunCommand acCmdSaveRecord

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
No, that doesn't work. I tried entering in the "DoCmd.RunCommand acCmdSaveRecord" logic within the OnDirty event property. I think the reason this doesn't work is because I'm not closing the form or pressing another button. I really don't want to add a "save" button either, which I know would work. It's like some other logic needs to be running in order to check if the form is "dirty". An On Close event or something. But that's my problem -- I don't want to close the form either, and I want the record to save after I update any field on the form.
 
Have you tried the LostFocus event procedure of the form ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Yeah, I tried On LostFocus as well. I've tried BeforeUpdate, AfterUpdate, OnDirty, OnLostFocus. None of them seem to work.

I mean, I could add the docmd.runcommand accmdsaverecord logic to the afterupdate property of the "Order Date", but if the user changes a different field other than the "Order Date" the record will not be saved. I would hate to add that logic to all 35 fields on the form.
 
Sorry, I meant the Deactivate event procedure.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV that worked! You don't even know how long I've played with this. Thanks so much for your help. You've helped me in the past and are very knowledgeable. Thanks again, and a star for you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top