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!

Event processing - before update and/or after update 1

Status
Not open for further replies.

JellyBelly

Technical User
Apr 27, 2001
2
US
I'm new to event processing, and trying to figure out something. I've got a form with subform, linked by Part_Name(text field). I've got this assigned to the Before Update. If I make a change to the Part_Name field, I want access to prompt me w/ Msg Box: "Changing Part_Name! Do you want to do this?" Buttons for Yes and Cancel. Cancel obviously would undo the change, Yes would change the field, and then update the form/subform. But I can't seem to get the subform to refresh. Could someone point me in the right direction? Thx! Also recommendations on good reference books would be much appreciated!
 
What code do you have in your BeforeUpdate event?

To get the subform updated, you should only have to execute a subformcontrol.Requery method, but you need it to be in the Form's AfterUpdate event. The actual record in the main table won't have been updated until then, so requerying the subform earlier will just look up the unchanged part number in the subform.

You can probably just requery the subform for every update, regardless of whether the part number was changed, but if you want to be more selective, create a boolean variable in the form's Declarations section and set it to True in the PartName_BeforeUpdate event. Test it in the Form_AfterUpdate event, and if it's on, turn it off and requery the subform. Rick Sprague
 
I forgot to mention: There is a set of forums specific to Access in Tek-Tips. You may get a quicker answer by posting there instead of in the Office forum. It would also have been more obvious that you were talking about Access in this post, since you didn't mention. Rick Sprague
 
Thanks! Someone else had mentioned to me about the After Update on the main form, so I'll try that. I realized after I left my question that I should have left it on the Access page. As this was my first ?? here, I now know better! Again, thanks for the tip - I'll try it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top