开发者

VBA access: Refreshing a form from another form's code

EDIT: nevermind someone helped me. form_(name).recalc or form_(name).refresh: form_main.recalc

I have two forms: "main", "details". In the "main" form, I have a button that opens "details" in a dialog. The problem is that I have a checkbox in "details" and when in changes, I nee开发者_开发问答d to refresh "main". What command do that? Thank you


I'm going to provide a different answer than the one you discovered for yourself:

Open the detail form with the acDialog switch, and then requery when it is closed. The event that opens the detail form would look like this (it would be in the main form):

  DoCmd.OpenForm "DetailForm", , , "ID=" & Me!ID, , acDialog 
  Me.Requery

What this does is pause the code with the detail form open. When you close the detail form, it will requery the main form.

This is the standard way of doing this kind of thing, seems to me.


To anyone who may come behind me, the method above did not work if you are opening a pop-up from a subform attached to a main form.

What does work is change the "Got Focus" property on your main form by adding Me.Requery.

What that does is automatically requery and update the records in the form as soon as the pop-up is closed... and focus is automatically shifted to the main form.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜