在Me.Recalc之后在Access中不显示屏幕外值 [英] After Me.Recalc in Access off-screen values are not displayed

查看:88
本文介绍了在Me.Recalc之后在Access中不显示屏幕外值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从VBA中,我设置了一系列文本框以具有DSum controlSources:

From VBA I'm setting a series of text boxes to have DSum controlSources:

Me.Oct.ControlSource = "=DSum('GBPValue', _
                                'MF YTD Actual Income & Adret', _
                                'Month=10 AND Org_Type=[Key]')"
Me.Nov.ControlSource = "=DSum('GBPValue', _
                                'MF YTD Actual Income & Adret', _
                                'Month=11 AND Org_Type=[Key]')"

,然后运行Me.Recalc以获取设置后显示的值.对于加载窗体时在屏幕上显示的文本框,此方法效果很好,但对于当前未在屏幕上显示的相同(非常宽)窗体上的文本框,Recalc似乎不起作用.如果我在表单上滚动并选择空白字段,则将显示值.有什么方法可以获取屏幕上每个文本框的值,也可以在表单加载时获取这些值,或者在用户滚动浏览时更糟?

and then running Me.Recalc to get the values to show up once set. This works fine for the text boxes that are on-screen when the form loads but for ones on the same (very wide) form that are not currently on screen the Recalc seems to do nothing. If I scroll across the form and select the blank fields the values then show up. Is there any way to get the values for every text box on-screen or off to be there on form load or, at worst, when the user scrolled across?

推荐答案

我可以猜测为什么必须这样做:Recalc可能不会重新绘制当前不可见的控件.因此,即使控件的值实际上发生了变化,但是当滚动窗口显示它们时,它们缓存的视觉外观仍然显示为空.

I can guess why this must be happening: it's likely that Recalc doesn't repaint controls that are not currently visible. So even though the value of the controls has in fact changed, their cached visual appearance still appears empty when the scrolling windows reveals them.

这是我的建议:像这样在您的表单上创建一个成员函数:

Here's what I'd recommend: create a member function on your form like this:

Function GetMonthValue(Month As Long) As Double
   GetMonthValue = DSum("GBPValue", "MF YTD Actual Income & Adret", _
                 "Month=" & Month & " AND Org_Type=" & [Key])
End Function

然后可以将文本框的控件源设置为"= GetMonthValue(1)",依此类推.这意味着每个控件的源都是静态声明的,并且在加载表单时无需更改任何内容.当前记录更改时,该值应该跟踪,尽管我尚未通过测试进行验证.

The control source for the text boxes can then be set to "=GetMonthValue(1)" and so on. This means that each control's source is declared statically and there's no need to change anything when the form loads. When the current record changes, the value should track, although I haven't verified this with testing.

这篇关于在Me.Recalc之后在Access中不显示屏幕外值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆