In access database I have a Main Form with a Tabular SubForm. I want each of the Main Form's control being recalculated upon changing any value of any record of the Sub Form. I tried applying something like (me.parent.recalc) to each of the subform's control but found that now when I change "any" of the subform's record the focus would offset to the same field of subform's first record. Any solution? Regards
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Assuming your sub form control on the main form is named ctlSubForm
, this would be a code sample you call in the subform, for example in an AfterUpdate
event procedure:
'Store the current sub forms record/bookmark
Dim currentRecord As Variant
currentRecord = Me.Bookmark
'Requery the main form, causing the first record of subform will be selected
'(instead place your existing code here)
Me.Parent.Requery
'Set the sub forms record/bookmark to the stored record/bookmark
Me.Bookmark = currentRecord
'Set the focus to the main forms sub form control
'(this is necessary to really get the focus back to the subform)
Me.Parent.ctlSubForm.SetFocus
回答2:
Try me.parent.recordset.requery That should refresh only underlying recordset, not the form itself. I am not shure 100% about syntax but I use that approach in my Access projects.
标签:
access-vba